• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
forwardInvocation: and keeping compiler happy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

forwardInvocation: and keeping compiler happy


  • Subject: forwardInvocation: and keeping compiler happy
  • From: Gerd Knops <email@hidden>
  • Date: Fri, 12 Jan 2007 12:42:25 -0600

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


  • Follow-Ups:
    • Re: forwardInvocation: and keeping compiler happy
      • From: Nir Soffer <email@hidden>
    • Re: forwardInvocation: and keeping compiler happy
      • From: "Julien Jalon" <email@hidden>
    • Re: forwardInvocation: and keeping compiler happy
      • From: j o a r <email@hidden>
  • Prev by Date: Re: fast bitmap image scaling
  • Next by Date: [notsoOT] xcode and iPhone
  • Previous by thread: Re: nstask with admin privs
  • Next by thread: Re: forwardInvocation: and keeping compiler happy
  • Index(es):
    • Date
    • Thread