Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert NSMutableData to NSString on iPhone?

I received an NSMutableData from a server and now I want to convert it to an NSString. Any ideas about how to do this?

like image 882
Chilly Zhong Avatar asked Feb 27 '09 03:02

Chilly Zhong


1 Answers

You can use the initWithData: initializer:

[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; 

Change the encoding to that of the source data.

like image 104
codelogic Avatar answered Sep 21 '22 18:09

codelogic