• 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: Get error message about registered observers when Object receives dealloc message
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get error message about registered observers when Object receives dealloc message


  • Subject: Re: Get error message about registered observers when Object receives dealloc message
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 29 Aug 2009 14:27:04 +0200


Le 29 août 2009 à 14:08, Andreas Grosam a écrit :


On Aug 29, 2009, at 2:29 AM, Graham Cox wrote:


Thank you Graham for your reply.

Hi Andreas,

There is a strong code smell here.

How does your observee know who its observers are?
Actually, it does not. My example code is an oversimplification to show the actual issue. Often, things are much more complex, and explainig them may draw people away from the actual problem. ;)

The *Observer*  will do this:

- (void) dealloc {
  [self.observee removeObserver:self forKeyPath:key];
}


However, in my code the *Observee* will receive the dealloc method first, which in turn causes all its "child" objects - the Observers - to receive its dealloc message - which is shown above. Here, the observee is the "parent" object that owns the child objects.



So, the call path is about this:

[observee release]
	[observee dealloc]
		[observer release]
			[observer dealloc]
				[obse
rvee removeObserver:observer forKeyPath:key]


Did you try on Snow Leopard.

http://developer.apple.com/mac/library/releasenotes/Cocoa/Foundation.html
Bug Fixes in Debugging of Objects Being Deallocated With Observers Still Registered When Not Running Garbage-Collected (Updated since March 2009 Seed)
[…]
There was another bug in which this logging was done spuriously when an object observed by a second object was deallocated, its deallocation caused the release of the second object, and the second object correctly unregistered itself as an observer of the first object at that time due to its own deallocation. This bug has also has been fixed in Mac OS 10.6.




_______________________________________________

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


References: 
 >Get error message about registered observers when Object receives dealloc message (From: Andreas Grosam <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Graham Cox <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Get error message about registered observers when Object receives dealloc message
  • Next by Date: "Format not a string literal and no format arguments"
  • Previous by thread: Re: Get error message about registered observers when Object receives dealloc message
  • Next by thread: Snow Leopard SDK for non "Premier" or "Select" ADC members
  • Index(es):
    • Date
    • Thread