Re: Accessing NSArray objects with a key path
Re: Accessing NSArray objects with a key path
- Subject: Re: Accessing NSArray objects with a key path
- From: Mike Ferris <email@hidden>
- Date: Thu, 31 Mar 2005 07:38:32 -0800
My problem is that I want @"arrangedObjects.key1" to return an NSArray
and
I want the table column to display only, say, the first object.
Something
to the effect of @"arrangedObjects.key1.objectAtIndex:0" or just
@"arrangedObjects.key1.0".
Is this kind of operation possible? Is there some array operator like
@max or @count that I am missing? I could write a custom formatter for
the column to pick off the part of the array I need but it seems like
there should be an easier way with the key paths. I have looked all
over
the documentation and old list threads but can't find any answers.
I've often wished for keyPath syntax that handled array indexing.
Your @"arrangedObjects.key1.0" would be the easiest to implement. All
you would need to do is override valueForKey:/setValue:forKey: on
NSArray to look for numeric keys and return objectAtIndex:.
A more satisfying (although trickier to implement yourself) syntax
would be @"arrangedObjects.key1[0]". For this you'd pretty much need
to replace the keypath methods...
Mike Ferris
_______________________________________________
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