• 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: Graham Cox <email@hidden>
  • Date: Mon, 31 Aug 2009 17:10:54 +1000


On 30/08/2009, at 7:46 PM, Andreas Grosam wrote:

This is not exactly what I got in the console. Actually it is:
"An instance 0xd21b60 of class MyObservee is being deallocated while key value observers are still registered with it. "


Notice:  "is being deallocated"

This is also **exactly** what happens in my code: the dealloc method has been sent to the observed object and - at this point - KVOs are still registered.


What I can't quite follow Andreas, is that *you* must be sending the - release message to the object, which in turn is calling dealloc. So why not just stop observing before you call release? That's what you're supposed to do. Call me dense (feel free!) but if you are unable to do that because of the design of your code, the code design needs to be fixed. Simple as.

I believe all the discussion about the logging of error messages is a red herring. If your code is broken, it's broken. Arguing about exactly which version words the message which way isn't helping you fix it. If the problem is that you are not retaining to avoid a retain cycle, and therefore are not in control of the release such that you can't stop observing just prior, that to me indicates a broken design. That's what you need to be sorting out.

As I understand it you have a situation where nodes of a tree are observing other nodes (sibling or otherwise) in the same tree, but at the same time these nodes are owned by their parent nodes, so cannot retain the other nodes that they are observing. Forgive my bluntness, but it sounds like a bad data structure design that was the product of one too many tequilas late on a Friday night! If a node even needs to observe another node in order to fulfil its function, maybe a tree structure isn't even the right design at all? Your solution of having some sort of shutdown message blowing all over your leaves is a band- aid on a gaping wound. Instead, why not strictly forbid nodes from observing other nodes, and instead move messages only along the branches. If a node needs to know what another node has done, it can do so because the single common node (or root) between the two passes that message. It means that the only KVO observers of a node allowed are its parent nodes (or root), which already owns it so it can simply stop observing when the child node is released.

--Graham


_______________________________________________

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: Roland King <email@hidden>)
 >Re: 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: Roland King <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Quincey Morris <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Roland King <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Quincey Morris <email@hidden>)
 >Re: Get error message about registered observers when Object receives dealloc message (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Two controllers in a window, how do I get one to run a function in another?
  • Next by Date: CGEventTap code fails on Snow Leopard
  • Previous by thread: Re: Get error message about registered observers when Object receives dealloc message
  • Next by thread: Re: Get error message about registered observers when Object receives dealloc message
  • Index(es):
    • Date
    • Thread