开发者

Convert from char* to NSString?

What is the best way to convert from char * to an instance 开发者_开发技巧of NSString?

I used the method -stringWithUTF8String:, but it's not good: the result contains "\n" at the end!


Create the string using the same method you're using now. Then, use a method like -stringByTrimmingCharactersInSet: to create the trimmed string that you really want.


Here's an actual code example to Convert from char* to NSString, as there was none in the other answer(s). For example with toBeConverted a char*:

NSString *convertedValue = [NSString stringWithUTF8String: toBeConverted];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜