Re: calling an Objective C method from C++
Re: calling an Objective C method from C++
- Subject: Re: calling an Objective C method from C++
- From: Andres Santiago Perez-Bergquist <email@hidden>
- Date: Thu, 27 Feb 2003 13:09:25 -0500
On Thursday, February 27, 2003, at 11:20 AM, Paul Cezanne wrote:
I'm trying to call an Objective-C method from a C++ object.
Converting the C++ object to Obj-C is not an option, this is cross
platform code.
Here is what I've done so far:
I define a C++ wrapper class with a pointer to the Obj-C object:
class CFooWrapper
{
public:
void myTest(int j, , char *str);
void setMyController(id c);
private:
id my_Controller;
};
Then implement this class, calling objc_send to send the onJunk
message to the receiver:
void CFooWrapper:: myTest(int j, char *str)
{
printf("j=%d, str=%s\n", j, str);
SEL aSel = @selector(onJunk:label:);
objc_msgSend(my_Controller, aSel, j, titleStr);
}
You should just be able to do "[myController onJunk:j
label:titleStr];" (at least if you follow the advice below).
At first I thought that I wasn't compiling with the Objective-C
compiler, so I changed it to be a .m file. That didn't help.
It seems that when compling this file, the compiler doesn't know what
id is. How can I make it know that? Thanks.
Make it a .mm file, for Objective-C++.
-- Andres
_______________________________________________
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.