Converting NSData to NSDictionary
You have to convert NSData
into UTF8 before parsing it using NSJSONSerialization
.
NSError* error = nil;
NSString *strISOLatin = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
NSData *dataUTF8 = [strISOLatin dataUsingEncoding:NSUTF8StringEncoding];
id dict = [NSJSONSerialization JSONObjectWithData:dataUTF8 options:0 error:&error];
if (dict != nil) {
NSLog(@"Dict: %@", dict);
} else {
NSLog(@"Error: %@", error);
}