기상 데이터를 Weather Underground API를 사용하여 Xcode 7.3.1, iOS 9.3 및 JSON으로 내 응용 프로그램에 구문 분석하려고합니다 (다른 API와 동일한 문제가 발생 함). OpenWeatherMap과 같은).JSON 직렬화에서 "스레드 1 : 신호 SIGABRT"오류가 발생했습니다.
내 응용 프로그램을 만들 때 오류가 발생하지 않지만 시뮬레이터에서 날씨를 호출 할 때 "스레드 1 : 신호 SIGABRT"오류가 발생합니다. 내 문제가 직렬화에서 왔다고 추측하기 위해 중단 점을 사용했습니다.
이미 프로젝트를 정리하려고했지만 이중 연결이 없었습니다.
#import "ViewController.h"
@interface ViewController()
@property (weak, nonatomic) IBOutlet UIButton *affichermeteo;
@property (weak, nonatomic) IBOutlet UILabel *meteo;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)affichermeteo:(id)sender {
NSData *allCoursesData = [[NSData alloc] initWithContentsOfURL:
[NSURL URLWithString:@"http://api.wunderground.com/api/e5cdee14984e242b/conditions/q/CA/San_Francisco.json"]];
NSError *error;
NSDictionary *allCourses = [NSJSONSerialization
JSONObjectWithData:allCoursesData
options:NSJSONReadingMutableContainers
error:&error];
if(error)
{
NSLog(@"%@", [error localizedDescription]);
}
else {
NSArray *currentobservation = allCourses[@"estimated"];
for (NSDictionary *theCourse in currentobservation)
{
_meteo.text=theCourse[@"weather"];
}
}
}
@end
내 오류 창 :
을 다운로드 내가 같은 문제가 this 튜토리얼의 프로젝트를 실행 ... 여기
내 코드입니다도움을 주셔서 미리 감사드립니다. 내 영어로 유감스럽게 생각합니다. 나는 프랑스 사람입니다!
어떤 라인이 충돌하나요? 그리고 질문을 편집하여 충돌에서 스택 추적을 추가 할 수 있습니까? (어떤 줄이 충돌을 일으키고 있는지 알려면 예외에 중단 점을 설정해야 할 수도 있습니다.) –
충돌은 "options : NSJSONReadingMutableContainers"줄에 나타납니다. – Jeremy
이것은 서버가 당신에게 JSON을 형편없이 만들어주고 있다고 제안합니다. 내용을 다른 JSON 구문 분석기 또는 JSON 유효성 검사기로 공급할 수 있습니까? –