Convert from char* to NSString?

眉间皱痕 提交于 2019-12-01 02:58:03

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/6325993/convert-from-char-to-nsstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!