Re: NSArrayController design/usage question
Re: NSArrayController design/usage question
- Subject: Re: NSArrayController design/usage question
- From: Steven Degutis <email@hidden>
- Date: Sun, 6 Sep 2009 12:00:21 -0500
Greg,
Generally these would be called "derived properties" from my experience, and
it's possible to add them on the classes that your Entities use, using KVO
methods. For instance, if you have 2 genuine properties on your "Person"
entity called firstName and lastName then you can create a fullName property
on your Person class, and when firstName or lastName change, call
-willChangeValueForKey: and -didChangeValueForKey: on "fullName" and then
have your -fullName method return a concatenation of the first and last
names. This doesn't work as well in your example of Now Playing, since it
has less to do with your model itself, but it works fairly well when you
have a property derived from other properties on your Entity.
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
On Sun, Sep 6, 2009 at 10:41 AM, Gregory Holden <email@hidden> wrote:
>
> NSArrayController seems great if you want to point it at repeating objects,
> but I can't find any clear way to add that one-off column that isn't part of
> the actual model objects (i.e. The "Now Playing" speaker in itunes, or a
> column with row numbers - independent of sorting).
>
> I've tried a couple things myself, but feel the best thing to do is throw
> NSArrayController away in these situations, and stick to the DataSource.
> Would this be an accurate assessment? How have others dealt with this
> problem?
>
> I did try setting up the bindings AND a datasource on the same table. It
> appears to work, but it also seems very dangerous as I'm obviously still
> getting requests for the bound data via tableView:objectValueForTableColumn.
>
> Thanks
> Greg
> _______________________________________________
>
> 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