I have not tried this, but for fun, I'm just going to riff on this:
At first it looks wrong:
@interface ObjC: NSObject { CppClass _cppClass; } @end
See that you are declaring a stack-based class in the obj c class interface.
Try
CppClass *_cppClass;
Then, while you include CppClass in your file
You have to since obj C interops with C and C ++ can create an instance with
_cppClass = new CppClass(pass constructor args here
I would not recommend putting a C ++ class in the same file
In the obj C project, you need a .mm file - not sure if CPP declarations are included. Do not do this.
So, you need a separate header and impl for your C ++ class, since usually you just include the CPP header and CPP code in your obj class as usual.
I could be here, haven't tried it, but obj C seems to gracefully call C and C ++ while you stick to the rules.
deleted_user
source share