I want to convert one NSString
to NSData
. on Using encoding am getting different value in NSData
by displaying it using its descripti开发者_C百科on property.
I have
NSString *str=@"80369F4";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
on printing [data description];
am getting some different values...
how to extract the same string from the NSData
.. pl help me out on this problem.
Create a new NSString:
NSString *newString = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease];
You can use NSString's initWithData:encoding: method:
NSString *str=@"80369F4";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSString *sameString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
精彩评论