• 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: Jeff Johnson <email@hidden>
  • Date: Sat, 20 Jun 2009 17:03:21 -0500

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

Le 20 juin 09 à 20:56, Quincey Morris a écrit :

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

- (void)dealloc {
[_object release];
[super dealloc];
}

Try changing this to:

- (void) dealloc {
	self.object = nil;
	[super dealloc];
}

'keyPathsForValuesAffectingName' is going to cause your wrapper to observe its MyObject (not the observation that you set up manually, but a different one set up internally). When the wrapper deallocs, there's apparently nothing to cause this internal observation to be removed, so the MyObject continues to be observed by a deallocated object. At least, that's my theory.


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

The interesting thing is that doing w1.object = nil right before [w2 addObserver:foo forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:[Foo class]] does prevent the problem.


I think this is a bug in KVO. You should file a Radar.

-Jeff

_______________________________________________

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

  • Prev by Date: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by Date: [WORKAROUND] Re: new NSTreeController bug in 10.5.7?
  • Previous by thread: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by thread: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Index(es):
    • Date
    • Thread