• 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: KVO willChange and didChange
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO willChange and didChange


  • Subject: Re: KVO willChange and didChange
  • From: Jens Alfke <email@hidden>
  • Date: Sun, 15 Jan 2012 23:13:02 -0800

On Jan 15, 2012, at 10:41 PM, Gordon Henriksen wrote:

> Try overriding +[NSObject(NSKeyValueObserving) automaticallyNotifiesObserversForKey:] to return NO for the properties you want to handle manually.

Or just don’t call will/DidChange in your setter methods. You don’t need them there — KVO automatically does that for you when a setter is called.

What will/DidChange are for is when you change a property’s value without invoking its setter. So if you had some code elsewhere that caused the value of the .foo property to change, you’d wrap those methods around the change. Obviously in your case you should just call setFoo instead, but there are cases when a property’s value isn’t stored explicitly as a variable, but is computed by the accessor method. So there’s no explicit variable and no sense in having a setter, but the value of the getter does change, and you have to let KVO know that.

—Jens_______________________________________________

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

  • Follow-Ups:
    • Re: KVO willChange and didChange
      • From: Roland King <email@hidden>
References: 
 >KVO willChange and didChange (From: Gideon King <email@hidden>)
 >Re: KVO willChange and didChange (From: Gordon Henriksen <email@hidden>)

  • Prev by Date: Re: KVO willChange and didChange
  • Next by Date: Re: KVO willChange and didChange
  • Previous by thread: Re: KVO willChange and didChange
  • Next by thread: Re: KVO willChange and didChange
  • Index(es):
    • Date
    • Thread