Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 808
hungbm06 Avatar asked Jun 13 '11 01:06

hungbm06


1 Answers

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.

like image 66
Caleb Avatar answered Oct 19 '22 21:10

Caleb