On Thu, Jul 21, 2011 at 12:08 PM, Jens Alfke <j...@mooseyard.com> wrote: > I’ve got a data model that looks sort of like this (expressed as JSON): > [{“uuid": “abcdef”, “name": [“Fred”, “Smith”]} … ] > I want to bind an array of these to an NSTableView, with the first and last > name in different columns. So I need to create a keypath that refers to the > first or second element of the array value of the “name” property. > > Is this possible? I’ve looked through the docs and can’t find anything about > it. I’ve guessed at paths like > name.0 > or > name[0] > but they throw exceptions at runtime.
Think about this for a second: this would involve creating an observer on [someArray valueForKeyPath:@"0"]. We know that NSArray is not KVO compliant, since its implementation of -addObserver:… is documented to raise an exception. Therefore this can't work. :) > (And no, I can’t change the schema to avoid having an array. It’s part of the > way the data comes back from the server.) Can you bind the entire "name" property and use a value transformer that extracts the desired component from the array? --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com