2016-06-18 1 views
0
NSData *jsonDataEncrypted = [jsonStringEncrypted dataUsingEncoding:NSUTF8StringEncoding]; 
NSDictionary *jsonDicEncrypted = [NSJSONSerialization JSONObjectWithData:jsonDataEncrypted options:kNilOptions error:nil]; 

위의 코드는 작동하지 않습니다.암호화 된 NSData를 NSDictionary로 변환하려면 어떻게해야합니까?

가 null jsonDicEncrypted.

+3

죄송 오류 – vadian

+0

의 종류를 파악하기 위해'error' 매개 변수를 사용하여, 나는 –

+0

오류가 "JSON 텍스트가 설정되지 않은 조각을 할 수 있도록 배열이나 객체와 옵션으로 시작하지 않았다"는 것을 잊어 버렸습니다. 다음에 무엇을해야합니까? NSData가 암호화되었습니다. –

답변

-1
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err]; 
    NSDictionary *jsons=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; 

사용이 코드

-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 
      }); 
      }]; 
관련 문제