How to correctly convert an NSDictionary to a json format , in iOS?
Your conversion is fine, NSData looks like that because it's a bunch of bytes!
You need to convert it to string, try this:
NSString* aStr;aStr = [[NSString alloc] initWithData:aData encoding:NSUTF8StringEncoding];
The method:
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error
Returns a NSData object, NSData is just an object wrapper for a byte representation, so your dictionary is there, but in the form of a byte representation.
Then you use:
- (instancetype)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
This method takes your byte representation and turn it into a string, using the encoding that you provide.