I am having an issue while trying to convert NSString
to NSData
and vice versa.
I am trying to store encrypted string to my database. For that I am
Please mind that NSASCIIStringEncoding
and NSUTF8StringEncoding
need to match the characters in the string.
NSString
to NSData
:
NSString* str= @"teststring";
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
NSData
to NSString
:
NSString* newStr = [[NSString alloc] initWithData:theData
encoding:NSUTF8StringEncoding];