• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
avoiding to open window multiple times
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoiding to open window multiple times


  • Subject: avoiding to open window multiple times
  • From: "Joris Mans" <email@hidden>
  • Date: Sun, 19 Feb 2006 17:16:42 +0100

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: avoiding to open window multiple times
      • From: Jerry Krinock <email@hidden>
References: 
 >Core Data Key-value question (From: "Bryan Zarnett" <email@hidden>)

  • Prev by Date: freeing data when closing window
  • Next by Date: Re: Core Data Key-value question
  • Previous by thread: freeing data when closing window
  • Next by thread: Re: avoiding to open window multiple times
  • Index(es):
    • Date
    • Thread