Re: Is it possible to traverse dictionaries and arrays using KVC?
Re: Is it possible to traverse dictionaries and arrays using KVC?
- Subject: Re: Is it possible to traverse dictionaries and arrays using KVC?
- From: Quincey Morris <email@hidden>
- Date: Tue, 16 Aug 2011 13:18:43 -0700
On Aug 16, 2011, at 13:02 , Kyle Sluder wrote:
> Either way, I believe you're correct, and there's no way to get at
> individual indexed members of an ordered collection via
> -valueForKeyPath:.
In the Land of Speculation …
I think it's in principle possible to have such a mechanism, though of course I haven't tried it.
Noting that a key path like "someObject.someArrayProperty.count" is valid, I think you could envisage key paths of the form "someObject.someArrayProperty.@0" and @1, @2, @3, etc. For this to work, "someObject.someArrayProperty" would have to return a NSArray subclass (or a compatible proxy object) that implements 'valueForUndefinedKey:' and recognizes the "indexing" properties from their key name syntax.
Such an implementation would be useful only in limited situations. Something has to generate the correct key syntax from the desired index value. (Those weird IB "patterns" might be useful for some cases.) KVO compliance might be infeasible, too.
But strictly from a KVC perspective, I believe the problem is formally solvable.
_______________________________________________
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