NSString:
NSString *string;
(1)NSString -> NSData:
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
(2)NSString -> const char*:
const char* chardata = [string UTF8String];
(3)NSString -> std:string
std::string stddata([string UTF8String]);
NSData:
NSData *data;
(1)NSData -> NSString:
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
(2)NSData -> const char*:
const char *chardata = [data bytes];
std::string:
std::string stdstring;
(1)std::string -> NSString:
NSString *string = [[NSString alloc] initWithCString:stdstring.c_str() encoding:NSUTF8StringEncoding];
(2)std:string -> NSData:
NSData *data1 = [[NSData alloc] initWithBytes:stdstring1.data() length:stdstring1.length()];
(3)std:string -> const char*:
const char *chardata = stdstring.c_str();
const char*:
const char *chardata;
(1)const char* -> NSString:
NSString *string = [[NSString alloc] initWithCString:chardata encoding:NSUTF8StringEncoding];
(2)const char* -> NSData:
NSData *data = [[NSData alloc] initWithBytes:chardata length:strlen(chardata)];
(3)const char* -> std::string:
std::string stdstring(chardata);