我该怎么做才能将加密的NSData转换为NSDictionary?

时间:2016-06-18 09:52:31

标签: ios nsdictionary nsdata

NSData *jsonDataEncrypted = [jsonStringEncrypted dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonDicEncrypted = [NSJSONSerialization JSONObjectWithData:jsonDataEncrypted options:kNilOptions error:nil];

上面的代码是无效的。

  

jsonDicEncrypted

为空。

2 个答案:

答案 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
             });
          }];