Re: New bindings for NSArrayController
Re: New bindings for NSArrayController
- Subject: Re: New bindings for NSArrayController
- From: Keary Suska <email@hidden>
- Date: Thu, 16 Nov 2006 11:57:26 -0700
- Thread-topic: New bindings for NSArrayController
on 11/16/06 10:36 AM, email@hidden purportedly said:
> I still have the accounts table, but now I would like to bind
> individual text boxes to the selection, instead of another table.
>
> I'd tried adding in a new method to NSArrayController - firstObject.
> This would just return the first element in the arrangedObjects list.
> I could then access its attributes. In my test app, it worked fine.
>
> But, unfortunately, my simplified view is a bit more complicated.
> While the firstObject binding works, it doesn't properly update. If I
> add a new item, it doesn't refresh, if I change the selection, it
> doesn't refresh, and so on.
>
> I set up setKeys:triggerChangeNotificationsForDependentKey: to trigger
> notifications for the firstObject parameter on changes in contentSet
> and arrangedObjects, but that wasn't enough. I'm not sure if I'm just
> missing the appropriate key to trigger off, of or if I need to
> subclass and override other methods, or if this approach just wont'
> work.
>
> So now I turn to you all.
>
> First question, of course, is, should I even be doing this? More aptly
> stated, is there a better way?
I would say that your firstObject idea may be a correct bark but that
NSArrayController is the wrong tree.
There isn't sufficient information provided to offer a decent solution but I
can recommend a couple approaches:
1 If you have a model object that "owns" the array that is the content of
the account detail arraycontroller, firstObject could be a property of the
model that you bind to through the account arraycontroller, presuming that
the array content is dependent on that controller's selection, as in a
master-detail interface. You could either set up a dependent key trigger on
the content array for use the setFirstObject: accessor.
2. If the above isn't viable, you could bind to the account detail
controller key "selection" and send -setSelectionIndex: every time the
master arraycontroller selection changes. This is likely a more complicated
solution, especially with Core Data.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden