Last active
August 29, 2015 13:56
-
-
Save FredericJacobs/9190073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(std::string *) objcDataToCppString:(NSData*)objcData { | |
return new std::string([objcData bytes], [objcData length]); | |
} | |
-(NSData*) cppStringToObjcData:(const std::string)cppString { | |
return [NSData dataWithBytes:cppString.c_str() length:cppString.size()]; | |
} |
I also recommend to return a pointer (or fill the string by reference) to avoid copying cost.
-(std::string *) objcDataToCppString:(NSData*)objcData {
return new std::string([objcData bytes], [objcData length]);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Warning: This is an updated Gist. @lrz helped me fix the bugs :)