• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing NSArray objects with a key path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Accessing NSArray objects with a key path
      • From: Todd Blanchard <email@hidden>
References: 
 >Accessing NSArray objects with a key path (From: email@hidden)

  • Prev by Date: Re: Nested sheets
  • Next by Date: Re: Apple's Code Level Support
  • Previous by thread: Re: Accessing NSArray objects with a key path
  • Next by thread: Re: Accessing NSArray objects with a key path
  • Index(es):
    • Date
    • Thread