Calling C++ method from Objective C

Calling C++ method from Objective C
0.0 0



I have a big trouble that i want to call C++ function from Objective-C but it does not easy for me.

This is the lifecycle:

CategoryScreen.cpp function => function => Call => Button press => call function categoryscreen.cpp again.

1.CategoryScreen.cpp function

void CategoryScreen::loadElementIntoViewRecord()

  1. function

void iOSBridge::addNativeRecordView_iOS(short int rows) {
id sth = [[UIApplication sharedApplication] delegate];
if ([sth isKindOfClass:[AppController class]]) {
SpeakHereViewController *speakViewController = [[SpeakHereViewController alloc] initWithNibName:`“SpeakHereViewController” bundle:nil withManyRows:rows];
speakViewController.view.frame = CGRectMake(585, 275, 156, 494);
AppController *controller = (AppController *) sth;
[controller.viewController.view addSubview:speakViewController.view];


[cell.btn_record addTarget:self action:`selector(recordComplete:) forControlEvents:UIControlEventTouchUpInside];

  1. When recording complete, i want to call void::CategoryScreen updateUI() in CategoryScreen.cpp but how I can call it ?

Please help me, thanks in advance !


I am not sure I fully understand the question but if you want to call a C++ function you need a target instance of the class and a pointer to its relevant method
then you call it:


This should help:


You can mix C/C++ and Objective-C in the same file, so you can just call your C function like you would normally. Make sure the file type is saved with a “.mm” extension, or manually change the compile type to “Objective C++”.



thank for your answers. it’s useful for me. I changed from cpp extension to mm. and i could do it.