On Jul 12, 2014, at 7:05 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:

> My object layout looks like:
> 
> -MyObject (custom NSObject)
> ---someProperty (Custom NSObject)
> ------propertyA (NSNumber)
> ------propertyB (NSNumber)
> ------propertyC (NSNumber)
> 
> Properties A, B and C use a binding to connect them to a user interface item
> with something like:
> 
> Bind to MyObject with key path someProperty.propertyA
> 
> If I have all three properties hooked up like this, it is easy to change the
> value of one of them with [someProperty setPropertyA:newValue] which updates
> in a KVC-friendly way and everything is good.
> 
> However, I would like to replace the entire someProperty object with a new
> object of the same class and have all the lower level bindings see the
> change in a KVC way.
> 
> Will doing [myObject setSomeProperty:newProperty] issue all the right KVC
> notifications so the bound objects update their values?

You're actually concerned about KVO here.  That said, the main way to achieve 
KVO-compliance for a property is to use KVC-compliant accessor names and then 
use those accessors when modifying the property.

Anyway, the answer is yes, all of the observers will update properly.  
KVO-compliance need only be implemented on a local, property-by-property basis. 
 It's not necessary to take a global perspective.  In general, an object 
wouldn't know which of its properties were being observed and definitely not 
which are being observed "through".

So, you only need to ensure that you're updating someProperty in a 
KVO-compliant manner and KVO takes care of the rest.  (And, of course, that 
propertyA, etc., are also updated in a KVO-compliant manner.)

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to