如何在c ++类中传递目标c ++实例

时间:2017-02-16 13:42:22

标签: c++ xcode objective-c++

我正在关注此URL,但我已经知道如何将我的目标c ++(。mm)实例传递给c ++类。 Calling Objective-C method from C++ method?

MyCPPClass.cpp  
#include "MyCPPClass.h"   
#include "MyObject-C-Interface.h"

int MyCPPClass::someMethod (void *objectiveCObject, void *aParameter)     
{  
// To invoke an Objective-C method from C++, use  
// the C trampoline function  
return MyObjectDoSomethingWith (objectiveCObject, aParameter);  
}

如何从目标c ++(。mm)调用MyCPPClass::someMethod (void *objectiveCObject, void *aParameter)我能从目标c ++(。mm)类传递void *objectiveCObject的值。

1 个答案:

答案 0 :(得分:0)

We can pass instance of objectiveC class to C++  - 

someMethod ((void*)CFBridgingRetain(self),aParameter)