I am trying to parse a feed from a json webservice on my iPhone however the utf8 conversion is not working the way it should or am I doing something wrong Here is apart of
In iOS 9 don't need do anything. It is converted automatically.
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request
fromData:postData completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"response header: %@",response);
NSString* aStr;
aStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"response data: %@", aStr);
NSDictionary * json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
for (NSDictionary *dict in json)
{
NSLog(@"%@", dict);
NSString *name = [dict objectForKey:@"name"];
NSString *msg = [dict objectForKey:@"message"];
NSString *topic = [dict objectForKey:@"topic"];
NSLog(@"*********** %@, %@, %@", name,topic,msg);
// now do something
}