How to convert NSData to NSString?

ios, objective-c, xcode

Solution

`NSString` provides an initializer for this purpose.

// NSData *data = [NSData data];
NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];

Problem

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?

Original source

Related problems