Mutech Dev01
Mutech Dev01

Reputation: 446

\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

Upvotes: 0

Views: 158

Answers (2)

Piyush
Piyush

Reputation: 1544

That may help you.

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

Upvotes: 0

Pablo A.
Pablo A.

Reputation: 2052

Try with this:

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

Upvotes: 1

Related Questions