• 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: Crash in KVO when using -keyPathsForValuesAffecting<Key>
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>


  • Subject: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 21 Jun 2009 14:12:54 +0200


Le 21 juin 09 à 11:26, Quincey Morris a écrit :

On Jun 20, 2009, at 14:15, Jean-Daniel Dupas wrote:

Thank you for the suggestion, but it does not solve the problem. Even trying w1.object = nil before unregistring the observer has no effect.

When I looked at your code a little harder, I realized my theory could not have been correct anyway. For a start, the MyObject was being leaked, so its dealloc would never be called.


On Jun 20, 2009, at 11:08, Jean-Daniel Dupas wrote:

[w1 removeObserver:foo forKeyPath:@"name"];
[w1 release];

Interestingly, changing this to:

[w2 removeObserver:foo forKeyPath:@"name"];
[w2 release];

works just fine, thought it ought to have exactly the same behavior as the original version. So here's a new theory ...


The observations you set up manually *both* cause a secondary/ indirect observation, where 'foo' observes (in effect if not actually) the "name" property of the *same* MyObject. In effect, you have the same observer object observing the same property of the same target object twice. (That's something you can't do directly, AFAIK.)

When a secondary/indirect observation needs to be removed (either because a manual observation is removed, or -- as we discovered when you tried 'w1.object = nil' -- for a different reason) it looks like the wrong one can get removed. Or something like that.

Gratz. That's a very elegant bug. :)


Thank you for your time.
That's my conclusion too. I filled a report, and I'm trying to workaround this bug by observing the "subproperty" myself instead of using automatic dependency tracking.



_______________________________________________

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: 
 >Crash in KVO when using -keyPathsForValuesAffecting<Key> (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Crash in KVO when using -keyPathsForValuesAffecting<Key> (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by Date: Core Data "Uniqueing" not happening as expected
  • Previous by thread: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by thread: Re: programmatically creating a NSMatrix with a prototype cell
  • Index(es):
    • Date
    • Thread