• 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
Re: calling an Objective C method from C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling an Objective C method from C++


  • Subject: Re: calling an Objective C method from C++
  • From: Tobias Sargeant <email@hidden>
  • Date: Fri, 28 Feb 2003 10:52:38 +1100

On Friday, Feb 28, 2003, at 05:58 Australia/Melbourne, Paul Cezanne wrote:

At 1:09 PM -0500 2/27/03, Andres Santiago Perez-Bergquist wrote:

You should just be able to do "[myController onJunk:j label:titleStr];" (at least if you follow the advice below).

I can't, but you don't know that because I left out one step. My C++ class is also not under my control, I have a callback I have to go through and I can't tell it about class. Very frustrating.

One of the joys of objective c is that you don't need to worry about this. The two methods
of sending an object a message are equivalent. If you don't have at least one class definition that
defines the message, however, the compiler will emit warnings. In all likelihood what you should be
doing is declaring a protocol which all wrapped objective c objects should adhere to.

I did however get it to work by replacing "id" with "void *" I hope that that is a "legal" solution.

try adding:

#import <Foundation/NSObject.h>

Toby.

For example, the following code compiles just fine:

#import <Foundation/NSObject.h>

@protocol CProto
- (void) onJunk: (int)x label: (const char *)y;
@end

class C {
public:
C(id<CProto> x) {
[x onJunk: 10 label: "foo"];
}
};

int main(int argc, char **argv) {
C(nil);
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: calling an Objective C method from C++ (From: Paul Cezanne <email@hidden>)

  • Prev by Date: Re: kitchens
  • Next by Date: Re: kitchens
  • Previous by thread: Re: calling an Objective C method from C++
  • Next by thread: File Types
  • Index(es):
    • Date
    • Thread