An other totally different angle to tackle the implementation would be to
use both inheritance and proxing with forwardInvocation.

having:

(something like) MyObject as RootClass
then, MyArray subclass MyObject and forwardInvocation to an inner NSArray
ivar
and MyMutableArray subclass MyObject and forwardInvocation to an inner
NSMutableArray ivar

then essentially, your specific classes, MyArray and MyMutable array end up
implementing:

- (void)forwardInvocation:(NSInvocation *)invocation {
[invocation invokeWithTarget:innerArray];
}

- (BOOL)respondsToSelector:(SEL)aSelector {
if ([super respondsToSelector:aSelector]) {
return YES;
}
    return [innerArray respondsToSelector:aSelector];
}

- (NSMethodSignature*)methodSignatureForSelector:(SEL)selector
{
    NSMethodSignature* signature = [super
methodSignatureForSelector:selector];
    if (!signature) {
signature = [innerArray methodSignatureForSelector:selector];
    }
    return signature;
}

So every call goes first down the standard inheritance chain, if not, gets
forwarded to the proxied array.

I believe this implementation is easier than playing with the runtime
copying methods.
_______________________________________________

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

Reply via email to