Re: forwardInvocation: and keeping compiler happy
Re: forwardInvocation: and keeping compiler happy
- Subject: Re: forwardInvocation: and keeping compiler happy
- From: "Julien Jalon" <email@hidden>
- Date: Fri, 12 Jan 2007 21:03:52 +0100
What about C cast?
[(ClassA *)bInstance aMethod:parameter];
--
Julien
On 1/12/07, Gerd Knops <email@hidden> wrote:
I have two classes, say ClassA and ClassB. Several instances of
ClassB need to share a single instance of ClassA.
Further I want to make the ClassB objects transparently respond to
everything ClassA implements.
I can't make ClassB a category, as it has it's own instance
variables. And I can't make it a subclass, as I need multiple ClassB
instances share a single ClassA instance.
So I use forwardInvocation: and friends for this, which works fine.
The question is how do I keep the compiler and myself happy. I'd like
the compiler to know about the methods of ClassA in the context of
ClassB, so it can perform all it's type checking. I can do that by
declaring everything ClassA implements as a protocol and have ClassB
tagged as implementing that protocol. Now the compiler compiles fine
and also performs all the type checking. But of course it warns that
ClassB does not actually implement the ClassA methods.
Is there a way to get around this, preferably without globally
disabling the otherwise useful warning "method definition for 'x' not
found"?
Thanks
Gerd
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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