1

I am following this URL but i have got struck that How can i pass my objective c++(.mm) instance to c++ class. 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);  
}

How can I call MyCPPClass::someMethod (void *objectiveCObject, void *aParameter) from objective c++(.mm) what can I pass the value for void *objectiveCObject from objective c++(.mm) class.

Community
  • 1
  • 1
Abhishek singh
  • 415
  • 7
  • 20
  • You gave a nice working link with an explanation yourself, what exactly doesn't work for you? – Gobra Feb 16 '17 at 14:10
  • I am unable to pass objective c instance in .cpp class in method "MyCPPClass::someMethod (void *objectiveCObject, void *aParameter)". How can I pass "void *objectiveCObject" from objective c class. – Abhishek singh Feb 16 '17 at 14:14
  • There's another way that works for me, please see: http://stackoverflow.com/a/42311096/6539779 – H. Al-Amri Feb 18 '17 at 05:25
  • What do you mean by "can't pass"? Do you get an error message? – uliwitness Mar 04 '17 at 16:49

1 Answers1

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

someMethod ((void*)CFBridgingRetain(self),aParameter)
Abhishek singh
  • 415
  • 7
  • 20
  • Hi and welcome to the StackOverflow. I'm afraid that your answer provides no explanation nor context. Could you give a few words explaining what exact problem does your code snippet solves? – Eel Lee Feb 16 '17 at 16:44
  • 2
    While this code may answer the question, providing additional context regarding why and/or how it answers the question would significantly improve its long-term value. Please [edit] your answer to add some explanation. – CodeMouse92 Feb 16 '17 at 18:29