반응형
여기서 발생하는 오류는 처리되지 않습니다.
iOS 앱에서 JSON을 구문 분석하는 데 문제가 발생했습니다.
관련 코드:
let jsonData:NSDictionary = try JSONSerialization.jsonObject(with: urlData! as Data, options: JSONSerialization.ReadingOptions.mutableContainers ) as! NSDictionary
/* XCode error ^^^ Errors thrown from here are not handled */
누가 나 좀 도와줄래?
에러가 발생했을 가능성이 있습니다.let jsonData = try JSONSerialization ...
처리되지 않습니다.
발생할 수 있는 오류를 무시하고 오류가 발생하면 패널티로 크래시할 수 있습니다.
let jsonData = try! JSONSerialization ...
또는 반환한다.Optional
,그렇게jsonData
이nil
에러 케이스:
let jsonData = try? JSONSerialization ...
또는 발생한 오류를 포착하여 처리할 수 있습니다.
do {
let jsonData = try JSONSerialization ...
//all fine with jsonData here
} catch {
//handle error
print(error)
}
언급URL : https://stackoverflow.com/questions/40470145/errors-thrown-from-here-are-not-handled
반응형
'programing' 카테고리의 다른 글
Data Contract Json Serializer 및 Enums (0) | 2023.02.09 |
---|---|
스프링 부트 액추에이터 엔드포인트의 응답 MIME 유형 (0) | 2023.02.09 |
Angular $q.는 일할 때 어떻게 됩니까? (0) | 2023.02.09 |
문서 프레임이 샌드박스로 인해 에서 스크립트 실행이 차단됨 - 각도 응용프로그램 (0) | 2023.02.09 |
값은 null일 수 없습니다.파라미터 이름: connectionString appsettings.json in starter (0) | 2023.02.09 |