2014-05-23 3 views
0

인터넷이 없으면 내 응용 프로그램이 충돌합니다. 이는인터넷이없는 경우 응용 프로그램이 충돌하는 것을 방지합니다.

NSDictionary *result = [NSJSONSerialization JSONObjectWithData:jsonData 
                   options:NSJSONReadingMutableContainers error:&error]; 

이 오류 'data parameter is nil'을 반환하기 때문입니다.

SDWebImage을 사용하여 jsonData을 캐싱 할 때 어떻게 이런 문제를 방지 할 수 있습니까? 인터넷이 없어도 그래야만 할 것입니다.

+0

왜 아래 표를 얻습니까? – maxisme

답변

6

에 대한 오류 MSG 얻을 수 있습니다 :

if (jsonData) { 
    NSDictionary *result = [NSJSONSerialization JSONObjectWithData:jsonData 
                   options:NSJSONReadingMutableContainers error:&error]; 
} 
0

너무에만 전무하고, JSON을하지 적절한 형식을 처리하지 당신은 당신은 코드가 데이터가 전무없는 단지 경우 실행되도록 할 수 있습니다 더

@try { 

     responseDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; 
    } 
    @catch (NSException *exception) { 
     NSLog(@"exception %@",exception); 
    } 
+1

답변에 의견을 추가하십시오 - 유일한 답변은 여기에 권장하지 않습니다! – LordT

관련 문제