Re: what do I need the NSArrayController for?
Re: what do I need the NSArrayController for?
- Subject: Re: what do I need the NSArrayController for?
- From: Roland King <email@hidden>
- Date: Thu, 03 Apr 2014 18:29:55 +0800
So where I ended up is understanding my model, which conflated available devices and selected device was flawed thus meaning I can't have two views each with a different selected device. So now that class just supports the list of devices. I'm using an Array Controller to mediate between that list and a table view, and bindings make that very easy and I don't have to read the Table View Programming Guide again
The only odd extra I've had to write is a small class which binds to the Array Controller (to get the arrangedObjects and the selectedIndexes, of which there is only ever 1) and vends an object representing the selected device, opened and working .. and closing it again if it becomes deselected. This seemed at the time an odd class to have to write, but that's code which would normally, before bindings, have been part of the table view data source/delegate huge block of code, using bindings just meant I needed to factor that piece out.
I still have a long, long way to go with bindings, not least of all learning when NOT to use them, but this has been a very helpful discussion.
On 3 Apr, 2014, at 8:02 am, Seth Willits <email@hidden> wrote:
> On Apr 2, 2014, at 4:34 PM, Roland King <email@hidden> wrote:
>
>> That sent me into the documentation to find that indeed there *is* a selected object property on NSArrayController, but it's a *property* not a binding.
>
> Note that the selection property value is a proxy which can represent a single object, multiple objects, no object, etc. So don't expect it to be a single instance of your class.
>
>
>
>> But there's more. That diagram also shows how the selected weapon flows back to the Combatant (thus meaning a combatant can only have one selected weapon :) ). That binds the property selection.selectedWeapon to a binding called .. selectedObject. Where is that binding? I checked the documentation and can find that on pop up buttons and matrices but not on a table view nor an NSArrayController.
>
> The weapon control is a popup, not a table view. It's showing the selectedObject binding of the NSPopUpButton.
>
>
>
>> That example states it's IB-only, no code required, is it just out of date? If it is, is there a way one could use bindings to accomplish what it's doing there, binding the selected object in a detail array directly back to a property on the selected object in the master?
>
> It's valid as is.
>
> The popup items are the weapons the combatant has (obtained via the first array controller's selection.weapons path), and then the selected item in that popup is determined by binding to the combatant's selectedWeapon (via the first controller's selection.selectedWeapon path)
>
>
>
> --
> Seth Willits
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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