Timur Mustafaev
Timur Mustafaev

Reputation: 4929

How to pass Objective C's class instance to c++ method?

I need to pass Objective C object instance to C++ method trough params. How I can do it?

This code doesn't work, and I know it. I'm just showing what I want.

MyObjcClass *instance = [[MyObjcClass alloc] init];
myCppClassInstance.myCppMethod(instance);

Upvotes: 1

Views: 1094

Answers (1)

KIDdAe
KIDdAe

Reputation: 2722

class is a keyword, so it won't work I agree. But for me there are no other issue in your sample code.

Juste declare your cpp method

void myCppMethod(MyObjcClass *obj) {

}

and use it like you did

MyObjcClass *obj = [[MyObjcClass alloc] init];
myCppMethod(obj);

Upvotes: 1

Related Questions