I have a simple NSString and I'm converting it to NSData :
NSData *data = [[NSData dataWithBytes:[[NSString stringWithFormat:@",%@",self.targetId] dataUsingEncoding:NSASCIIStringEncoding]
length:[[NSString stringWithFormat:@",%@",self.targetId] lengthOfBytesUsingEncoding:NSASCIIStringEncoding]] retain];
Now I want to get the plain text from the NSData object.
If I'm doing that :
NSString* dataStr = [NSString stringWithFormat:@"%@",data];
- I'm getting just an hex expression (i.e <9c3f473e 02000000 0b0000>) and not the plain string I want !
I've tried also using initWithData -
NSString* dataStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
But it always shows gibrish, no matter which encoding I give it.
Can you please help here ?? :)