简体   繁体   中英

\n for NSString not work for string from NSData

I retrieve NSData from a server containing \\n . When I convert it into an NSString , \\n is not working. It prints "\\n".

My code is like this:

 NSString *st=[NSString stringWithFormat:@"%@",data];

Thanks

试试这个:

NSString * string = [[NSString alloc] initWithData:yourData encoding:NSUTF8StringEncoding];

那可能对您有帮助。

myString = [myString stringByReplacingOccurrencesOfString:@"\n" withString:@" "];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM