I have a C++ class in my Objective C ARC project. The class is derived from a pure C++ class and adds a platform specific implementation for my iOS project. I want to call Objective C functions and frameworks there.
I implemented the platform specific parts using C++11 lambda functions. Can I do it that way? Any hidden pitfalls (especially because my iOS project uses ARC)?
bool MyDerivedCPPClass::getValue(const std::string& stdKey, std::string& stdValue) const
{
NSString *key = [NSString stringWithUTF8String:stdKey.c_str()];
// Do ObjC stuff
if(value)
{
stdValue = std::string([value cStringUsingEncoding:NSUTF8StringEncoding]);
return YES;
}
else
{
return NO;
}
}
It looks fine (generally Objective-C does not interfere with C++), aside from:
boolshould betrue/false, notYES/NO