Convert between NSString and NSData
With Objective C in iOS, we can convert the value of NSString
to NSData
.
NSString* str = @"Hello World!";
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSData
to NSString
.
NSString* newStr = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding];
Using UTF-8 encoding.