• 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: Observing properties which are not objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Observing properties which are not objects


  • Subject: Re: Observing properties which are not objects
  • From: Graham Cox <email@hidden>
  • Date: Tue, 28 Apr 2009 20:39:09 +1000


On 28/04/2009, at 8:23 PM, Andreas Grosam wrote:

Maybe I miss something, but it seems, the standard KVO does not work for properties whose values are non-objects, say int, float etc.


How can I effortless accomplish to observe at such properties?


Scalar properties (int, float, etc) are automatically wrapped in a NSValue/NSNumber instance when using KVC and KVO.

And, btw., how can Model determine whether an observer is added to one of its properties?


In general, it can't. And in general, it doesn't need to know. If you follow the rules you shouldn't need to know. It does take a little bit of grokking at first, because when I first approached KVO that was my first question to myself also. Hence my first design sucked. Later, I realised that a good design doesn't require this knowledge things got a whole lot easier, particularly when de-observing (if that's the right term).

--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: 
 >Observing properties which are not objects (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Dividing NSView to subviews
  • Next by Date: NSPopUpButton update
  • Previous by thread: Observing properties which are not objects
  • Next by thread: NSPopUpButton update
  • Index(es):
    • Date
    • Thread