Re: Refreshing Cocoa Bindings

2017-01-12 Thread Gordon Apple
Just don't try binding to an arrayController via representedObject. I've
resorted to using representedObject to establish a local iVar to reference
such an arrayController. That works.


On 1/12/17 1:42 PM, "cocoa-dev-requ...@lists.apple.com"
 wrote:

> 
On Jan 11, 2017, at 13:16 , Daryle Walker  wrote:
> 
> I'm
> going to store a reference to a model in a NSViewController's
> representedObject field. The various contained views will reference that field
> through KVO (Is that possible?) for their bound values. If I change the value
> of the represented object (what it points to, not any attributes within), will
> the views automatically track to the new object? Or do I have to use a
> explicit method to let them know (i.e. clear their caches)?

The
> ³representedObject² property is explicitly documented as KVO compliant, so you
> can observe and and bind through it.





___

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

Re: Refreshing Cocoa Bindings

2017-01-11 Thread Ken Thomases
On Jan 11, 2017, at 3:16 PM, Daryle Walker  wrote:
> 
> I'm going to store a reference to a model in a NSViewController's 
> representedObject field. The various contained views will reference that 
> field through KVO (Is that possible?) for their bound values.

Yes, that's possible.  The issue is how that binding is established and by what 
code/mechanism.  It will need a reference to the specific view controller.

> If I change the value of the represented object (what it points to, not any 
> attributes within), will the views automatically track to the new object?

So long as any change along the key path is made in a KVO-compliant manner, KVO 
will track it.  Changing a property by calling its setter method is 
KVO-compliant.  You have little choice but to use the setter method to change 
NSViewController's representedObject (unless you completely override that 
property), so changing it is KVO-compliant.

> Or do I have to use a explicit method to let them know (i.e. clear their 
> caches)?

No.

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


Re: Refreshing Cocoa Bindings

2017-01-11 Thread Quincey Morris
On Jan 11, 2017, at 13:16 , Daryle Walker  wrote:
> 
> I'm going to store a reference to a model in a NSViewController's 
> representedObject field. The various contained views will reference that 
> field through KVO (Is that possible?) for their bound values. If I change the 
> value of the represented object (what it points to, not any attributes 
> within), will the views automatically track to the new object? Or do I have 
> to use a explicit method to let them know (i.e. clear their caches)?

The “representedObject” property is explicitly documented as KVO compliant, so 
you can observe and and bind through it.

___

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

Refreshing Cocoa Bindings

2017-01-11 Thread Daryle Walker
I'm going to store a reference to a model in a NSViewController's 
representedObject field. The various contained views will reference that field 
through KVO (Is that possible?) for their bound values. If I change the value 
of the represented object (what it points to, not any attributes within), will 
the views automatically track to the new object? Or do I have to use a explicit 
method to let them know (i.e. clear their caches)?

Sent from my iPhone
___

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