Re: TreeController and "selection" Binding
Re: TreeController and "selection" Binding
- Subject: Re: TreeController and "selection" Binding
- From: Michael de Haan <email@hidden>
- Date: Fri, 12 Feb 2016 14:24:01 -0800
> On Feb 12, 2016, at 2:16 PM, Quincey Morris <email@hidden> wrote:
>
> On Feb 12, 2016, at 14:00 , Michael de Haan <email@hidden <mailto:email@hidden>> wrote:
>>
>> I could not get from that binding to the actual instance of my model. There does not seem to be an “Array.ObjectAtThisIndexPath" which I think you are alluding to? Ie bind this to a local variable (indexPaths) and derive the instance of the model from this?
>
> I still don’t understand what you’re saying. A binding binds to a *property* of an object — limited by IB to the objects that are available in the context. In a storyboard scene with a view controller at the top level, this property must be a property of the view controller. However, if the view controller has properties that lead elsewhere, you can use a key path to extend your reach.
>
> For example, if the view controller itself has a “selectedIndexPaths” property, you can bind to that. If this property is in a data model instead, you’ll need to give the view controller a “model” property, and bind to “model.selectedIndexPaths”. And so on. It’s a bit harder in a storyboard than a XIB, because you can’t bind directly to the world outside the view controller (e.g. the window controller) without going through the view controller.
>
> Do you perhaps mean a private instance variable?
Yes… I do. And, if I understand you correctly, using the “selectionIndexPaths” binding of the TreeController (from IB) I should be able to use that information to trace it back ( with key paths) to my model instance. Let me play around with that, but I suspect that this is the way to solve this… certainly more elegant than I am trying to.
_______________________________________________
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