从char *转换为NSString? [英] Convert from char* to NSString?
本文介绍了从char *转换为NSString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从char *
转换为NSString
的实例的最佳方法是什么?
我使用了方法-stringWithUTF8String:
,但是效果不好:结果的末尾包含"\ n"!
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!
推荐答案
使用与现在使用的相同方法创建字符串.然后,使用-stringByTrimmingCharactersInSet:
之类的方法来创建您真正想要的修剪后的字符串.
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.
这篇关于从char *转换为NSString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文