I want to call and work with Objective-C classes from within a C++ project on OS X. It is time to start moving towards all Objective-C, but we need to do this over some time
First rename your files from *.m to *.mm so you get Objective-C++
I have not tired this, so it is speculation (I will tonight):
As all Objective-C++ objects (that are reference counted) are controlled via pointers so you can write a special destructor for shared pointer.
template
struct ObjCDestruct
{
void operator()(T* obj)
{
[obj release];
}
};
Now you can stick your Objective-C obects in a boost::shared_ptr
// FuncFile.M
//
int func()
{
boost::shared_ptr > data([[MyX alloc] init]);
[data.get() doAction1:@"HI"];
}