You can create a C ++ object in your Objective-C class by creating a new instance of your C ++ class inside your init method, assigning it to ivar, then in -dealloc call delete in ivar:
@interface SomeClass : NSObject { SomeCPPClass *cpp_object; } @end @implementation SomeClass - (id) init { self = [super init]; if(self) { cpp_object = new SomeCPPClass(); } return self; } - (void) dealloc { delete cpp_object; [super dealloc]; } @end
source share