• 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
Re: Notification Issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notification Issue


  • Subject: Re: Notification Issue
  • From: j o a r <email@hidden>
  • Date: Thu, 11 Sep 2003 21:13:27 +0200

Post the notification from the "windowWillClose:" notification / delegate method instead of the dealloc method.

A quick question about your design. Why does one window need to know about the other window disappearing? Is it an inspector window? In that case you might consider listening to the "didBecomeKey:" and / or "didBecomeMain:" methods from the document windows and at that time subscribing the inspector window for "windowWillClose:" notifications from the document window - if you do that you don't have to manage any notification yourself.
Always avoid writing code for a functionality that the system already provides!

j o a r

On 2003-sep-11, at 20:23, John Nairn wrote:

My application has two types of documents and one type needs to know if
the other one has just closed. I implemented the process by posting a
notification in the dealloc method of the second document type with
object self.

But then I noticed in Apple documentation on posting notification that:

notificationWithName:object:

+ (id) notificationWithName: (NSString *) aName object: (id) anObject
Returns a notification object that associates the name aName with the
object anObject .aName may not be nil .

This method copies aName and retains anObject .

My concern is that self (passed as anObject) will be retained while
being deallocated. It seems to work fine, but is such a notification
posting in delloc method forbidden?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Notification Issue (From: John Nairn <email@hidden>)

  • Prev by Date: Re: Notification Issue
  • Next by Date: Re: 2 questions on Cocoa design and "expected" behavior
  • Previous by thread: Re: Notification Issue
  • Next by thread: Re: Notification Issue
  • Index(es):
    • Date
    • Thread