I have an object that I would like to respond to a potentially large
number of KVC compliant to-many accessors of the form:
-countOf<key>
-objectIn<key>:atIndex:
so that they can be used with valueForKey: to return a proxy array, or
just called directly.
Rather than implement these as methods (and because <key> specifies
the array behavior), I want to be able to create them dynamically and
have all accesses to
-countOf<key>
-objectIn<key>:atIndex:
be handled by two central methods:
-countOfForKey:
-objectInForKey:atIndex:
that respond according to <key>.
I had thought that implementing forwardInvocation would do this, but -
forwardInvocation is only called if -respondsToSelector says NO. And
if -respondsToSelector says NO, then the tests for -countOf<key> and -
objectIn<key>:atIndex: will always fail and I will lose KVC compliance.
Another approach would be to override -valueForUndefinedKey:, but that
gives me the responsibility of creating and returning the proxy
NSArray that implements accesses to -countOfForKey: and -
objectInForKey:atIndex:
Is there a better way to be KVC compliant and yet create the methods
dynamically?
Steve Weller [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [EMAIL PROTECTED]