51

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

pnuts
  • 58,317
  • 11
  • 87
  • 139
Chilly Zhong
  • 16,763
  • 23
  • 77
  • 103

1 Answers1

79

You can use the initWithData: initializer:

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

Change the encoding to that of the source data.

codelogic
  • 71,764
  • 9
  • 59
  • 54