NSMutableString到char *

时间:2011-11-02 22:39:28

标签: objective-c nsstring cstring

Hot我可以将NSMutableString转换为char *?

e.g。

NSString* someval = @"This is a test.";
NSMutableString *temp = [NSMutableSTring stringWithString:someval];
char * temp2 = ????Not sure what to do here???;

1 个答案:

答案 0 :(得分:5)

使用-UTF8String方法:

NSString* someval = @"This is a test.";
NSMutableString *temp = [NSMutableString stringWithString:someval];
const char * temp2 = [temp UTF8String];