• 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
bindings keypaths and collections
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bindings keypaths and collections


  • Subject: bindings keypaths and collections
  • From: William Squires <email@hidden>
  • Date: Sun, 29 Jul 2012 13:15:00 -0500

If a class declares an @property that's a reference to one of the collection classes (or a mutable variant thereof), such as NSArray, NSDictionary, NSSet, etc… can a key path (for bindings) refer to on object in that collection? If so, what's the syntax?

Ex: my GameEngine class has an @property (nonatomic, strong) Player *player;

The Player class, in turn, has an @property (nonatomic, strong) NSMutableArray *inventory;

and the following method

-(void)addThing:(Thing *)theThing;

If I want to refer to a 'Thing' in the player's inventory using a key path, how would I do it?

i.e. [[GameEngine sharedEngine] valueForKeyPath:@"player.inventory???"] to return an id pointer to some Thing object in the player's inventory (let's say I want the first one - [inventory objectAtIndex:0])?

Can I do @"[player.inventory objectAtIndex:0]" as the path?


_______________________________________________

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


  • Follow-Ups:
    • Re: bindings keypaths and collections
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: NSDocument window opens - even if the document didn't read properly.
  • Next by Date: Re: NSDocument window opens - even if the document didn't read properly.
  • Previous by thread: Re: NSDocument window opens - even if the document didn't read properly.
  • Next by thread: Re: bindings keypaths and collections
  • Index(es):
    • Date
    • Thread