Prevent windows from opening multiple times
Prevent windows from opening multiple times
- Subject: Prevent windows from opening multiple times
- From: Luc Van Bogaert <email@hidden>
- Date: Fri, 21 Jan 2011 19:48:19 +0100
Hi,
I've implemented a simple Preferences window using example code from a Cocoa handbook. When opening the window, the window controller is created and initialized with a nib file. When closing the window, the window object resources are (auto)released in the windowWillClose delegate method.
This seems to work fine, except for one problem: it is possible for the user to open multiple instances of the same window. I would like to prevent this, but I'm not sure what would be the best way to do this.
Instead of using a local pointer variable in the action method to open the window, I thought about using an instance variable in my app delegate to hold a pointer to the windowcontroller object, and check its existance before opening the window. However, trying this failed, as now I can open and close the window just once, and the app crashes on subsequent attempts to open the window.
Any help would be appreciated.
Thanks,
--
Luc Van Bogaert
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden