How to convert NSMutableData to NSString on iPhone?

IphoneStringTypeconverter

Iphone Problem Overview


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

Iphone Solutions


Solution 1 - Iphone

You can use the initWithData: initializer:

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

Change the encoding to that of the source data.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChilly ZhongView Question on Stackoverflow
Solution 1 - IphonecodelogicView Answer on Stackoverflow