Calling an Obj-C method from a C++ class, how?
Calling an Obj-C method from a C++ class, how?
- Subject: Calling an Obj-C method from a C++ class, how?
- From: Rolf Nilsson <email@hidden>
- Date: Thu, 7 Oct 2004 15:17:48 +0200
Hi,
My app has a Cocoa GUI but most of the code is C++.
My problem is how to call an Obj-C method from a C++ class.
This is what I do:
When I create my C++ object in my Cocoa method, I supply a pointer to
the Cocoa class:
@implementation MyController
- (void)someCocoaMethod
{
SomeCPPClass *p = new SomeCPPClass(self);
}
- (void) aCocoaMethodWithOneArgument:(int)theArgument;
- (void) aCocoaMethodWithTwoArguments:(int *)pAnIntPointer
anIntValue:(int) anIntValue;
@end
in my C++ class I want to be able to call either of the two methods
aCocoaMethodWithOneArgument or aCocoaMethodWithTwoArguments
class SomeCPPClass
{
public:
SomeCPPClass(MyController *pMyControllerCocoaObj) {
m_pMyControllerCocoaObj = pMyControllerCocoaObj; }
void foo();
protected:
MyController *m_pMyControllerCocoaObj;
}
// here I want to call (send a message to ) the Obj-C method
void SomeCPPClass::foo()
{
int * pAnIntPointer;
int anIntValue;
............
other code here
............
// this works for a method with one argument but there may be a better
way?
[ (id)m_pMyControllerCocoaObj
performSelector:@selector(aCocoaMethodWithOneArgument:) withObject:
(id) pAnIntPointer];
}
But, I can't find out how to call the method with two arguments?
Thanks for any help,
Rolf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden