NSData *jsonDataEncrypted = [jsonStringEncrypted dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonDicEncrypted = [NSJSONSerialization JSONObjectWithData:jsonDataEncrypted options:kNilOptions error:nil];
上面的代码是无效的。
jsonDicEncrypted
为空。
答案 0 :(得分:-1)
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err];
NSDictionary *jsons=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
使用此代码
答案 1 :(得分:-1)
检查一下。
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *connectionError) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
//UI update here
});
}];