Steve,

First, have you considered the low tech approach of using a gcc variadic macro (#define) ? <http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html > You can generate a lot of template code this way. With one line of code per key you can generate all the accessors you need.

A second option would be to override -mutableArrayValueForKey: to return a proxy object that knows both the source object and the key and fulfills the mutable KVC contract. Basically, this is creating a subclass of NSMutableArray that knows how to properly handle your source object, it's key.

On 10.5, you have an additional hook that is invoked before forwarding:

+ (BOOL)resolveInstanceMethod:(SEL)sel;

This is much more efficient than forwarding, and the result is cached, so method resolution is only invoked once per selector. It does require some nasty "parsing" of the selector, and use of the raw objective-c runtime functions to register the new method on the class.

-forwardInvocation: is the least efficient choice, although it can be handy under some circumstances where flexibility is the most important design issue.

- Ben

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to