NSString转std::string
NSString *str = @"it is nsstring"; std::string str = std::string([str UTF8String]);
std::string转NSString
如果是没有中文字符,就使用:
string path = string("原图17.png");NSString* pathString = [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
有中文字符就使用:
string path = string("原图17.png");NSString* pathString = [NSString stringWithCString:path.c_str() encoding:NSUTF8StringEncoding];
来源地址:https://blog.csdn.net/weixin_44210987/article/details/123575595