Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert NSData to NSString? [duplicate]

Possible Duplicate:
Convert UTF-8 encoded NSData to NSString

I need to to convert the NSData read from file to NSString. How to do it?

like image 200
tna0y Avatar asked May 12 '12 16:05

tna0y


1 Answers

NSString provides an initializer for this purpose.

// NSData *data = [NSData data]; NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; 
like image 62
modocache Avatar answered Oct 12 '22 15:10

modocache