[Solved] Literal converstion NSData to NSString [closed]


HINT#1 //general answer

NSString provides an initializer for this purpose. You can see more info using the docs here.

NSString * str = [[NSString alloc] initWithData: mynsdata 
                                      encoding:NSUTF8StringEncoding];

Assuming you use ARC.

HINT#2 // the answer for hex nsdata

int len = [mynsdata length];
NSMutableString *str = [NSMutableString stringWithCapacity:len*2];
const unsigned char *nsdata_bytes = [mynsdata bytes];
for (int i = 0; i < len; ++i) {
    [str appendFormat:@"%02x", nsdata_bytes[i]];
}

1

solved Literal converstion NSData to NSString [closed]