PDA

View Full Version : Double NSWindows


Jake
2004.11.19, 06:24 PM
I am getting some reports of multiple windows coming up. After my second round of golf I start to see them too, here is the code


NSWindow *infoWindow = NSGetAlertPanel( @"Score", @"Triple Bogey", @"Crap.", nil, nil );
[NSApp runModalForWindow:infoWindow ];
[infoWindow close];


On the first round of golf it waits until you close it to go to the next hole, but on the second round I think (not going to play 18 holes to test) it waits for the first window to be closed but not the second.

Any ideas? I am almost 100% sure my program only hits that piece of code once.

Steven
2004.11.19, 09:21 PM
Stick a NSLog in to make sure it's only called once. And aren't you supposed to use orderOut: and not close?

Jake
2004.11.19, 09:56 PM
Thanks Steven, that showed me two errors. First the orderOut fixed the multiple windows, but the NSLog was getting called as many times as you played the game, so that made me realize that I wasn't turning off the timer each game!

Taxxodium
2004.11.20, 03:10 AM
Instead of creating a window each time, why don't you use NSBeginAlertSheet()?