Wednesday, 7 August 2013

NSWindow crashes on reopen

NSWindow crashes on reopen

I am creating an NSWindow and displaying it. When the user closes the
window and opens it again, the app crashes with an EXC_BAD_ACCESS error (I
am using ARC). I am creating an instance variable with a strong reference
in my header file.
NSWindow *__strong detailWindow;
I am displaying the window with the following. This is called when a
button is clicked.
detailWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 624,
416) styleMask:NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask backing:NSBackingStoreBuffered defer:NO];
[detailWindow setContentView:detailView];
[detailWindow makeKeyAndOrderFront:nil];
When the window is opened, closed and opened again, the app crashes with
EXC_BAD_ACCESS.

No comments:

Post a Comment