I'm writing an Objective-C++ class interface that has to be usable from both Objective-C and Objective-C++. The problem is that, because it must be usable from Objective-C, I cannot simply use a C++ type. I want to do it using pointers and I came up with this:
@interface SXDiff : NSObject {
@private
#ifdef __cplusplus
dtl::Diff<std::string, std::vector<std::string> > *_diff;
#else
void *_diff;
#endif
}
...
@end
Can any problems occur when doing this? Is there a better way of doing this?
Note that the use of pointers is just to get the size of the ivar to be the same in both Objective-C and Objective-C++. The ivar can only be used from within the class implementation of SXDiff (it's @private). The implementation is written in Objective-C++.
dtl::Diffin the implementation file using a class extension.