• 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: Implementing Manual KVO For Bitfields Set in Atomic Operations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing Manual KVO For Bitfields Set in Atomic Operations


  • Subject: Re: Implementing Manual KVO For Bitfields Set in Atomic Operations
  • From: Seth Willits <email@hidden>
  • Date: Tue, 21 Aug 2012 09:20:30 -0700

On Aug 21, 2012, at 3:53 AM, Andreas Grosam wrote:

> So, in order to implement KVO, I would need to track changes of the ivar _state, and invoke
> -willChangeValueForKey:, and
> -didChangeValueForKey:
> appropriately.
>
> But, how exactly can I accomplish this with the given code above?

You can call will/did around a change which doesn't actually change the value, so it becomes straightforward.


Also, especially if the number of fields grows, you may want to have a KVC "state" property (not necessarily public), and use

+ (NSSet *)keyPathsForValuesAffectingFoo / Bar; { return [NSSet setWithObject:@"state"]; }

That way you only need to do will/didChangeValueForKey:@"state" and the other KVO methods get triggered as well, instead of having to next multiple will/dids for each key (foo, bar, blah, blah) around every state change.


--
Seth Willits





_______________________________________________

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: 
 >Implementing Manual KVO For Bitfields Set in Atomic Operations (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Focus issues with NSTableView in NSPanel
  • Next by Date: Re: Set icon for files and folder
  • Previous by thread: Implementing Manual KVO For Bitfields Set in Atomic Operations
  • Next by thread: Re: Implementing Manual KVO For Bitfields Set in Atomic Operations
  • Index(es):
    • Date
    • Thread