views:

33

answers:

1

Hello,

Im sure this is something really simple I'm missing. I use makeKeyAndOrderFront: to open a window and it works the first time. When I close the window and try and open it again it quits and gives me the error EXC_BAD_ACCESS. My code is this:

- (IBAction)viewScreen:(id)sender {

[screenView makeKeyAndOrderFront:sender];
}

I can't figure out why this is happening and the debugger console isn't saying much of anything.

Thanks in advance

+3  A: 

Why are you calling your window variable screenView? That sounds like it should refer to a view, not a window.

Check whether your window has the “Release when closed” property turned on in IB. When that property is on, the window will release itself when anything or anybody closes it. This can be handy, but if you intend to show the same window again later on, it's probably not what you want.

More generally, you can use Instruments's Zombies instruments to debug crashes like this.

Peter Hosey
The window was called screenView because it had a vie in it, yes I agree not a very good name. "Release when closed" was on and and turning it off fixed the problem. Thanks so much.
happyCoding25