Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoiding to open window multiple times



Hello,

I have multiple nib files in my application, one for each kind of data i want to edit in an assoc.d window. (e.g. 1 nib file containing instances and the window to edit an addressbook, etc) as explained in the Apple docs. Now I want to make sure that when a user opens a window through the menu, and the window exists already, that the app doesnt instance the window a second time.

I load and show the window using an NSWindowController using iniWithWindowNibName.
I add the controller to a list in my object and add a notification


[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowClosed:) name:NSWindowWillCloseNotification
object:[window_controller window]];

When initing the window using the controller, i take the NSMenuItem which caused the action, and remove its target by setTarget:nil so it effectively gets greyed out and unusable.
When the close notification is received i put the target back so the user can click on it again to reopen the window.


Is this a good way of handling this? Isnt there a better way?

Joris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Core Data Key-value question (From: "Bryan Zarnett" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.