Re: Observing properties which are not objects
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