我曾经能够完美地解析这个 JSON,完全没有错误,但突然间它停止了工作,而且它不是我的 API 密钥......
这就是我要解析的内容:http: //pastebin.com/vv8ScBfZ
这是我的解析代码:
NSError *myError = nil;
NSDictionary *flighttrackjson = [NSJSONSerialization JSONObjectWithData:jsonresponse options:NSJSONReadingMutableLeaves error:&myError];
NSArray *FlightStatus = [flighttrackjson objectForKey:@"flightStatuses"];
NSString *FlightID = [FlightStatus valueForKey:@"flightId"];
NSString *DepartACode = [FlightStatus valueForKey:@"departureAirportFsCode"];
NSString *ArivalACode = [FlightStatus valueForKey:@"arrivalAirportFsCode"];
NSArray *DepartATime = [FlightStatus valueForKey:@"departureDate"];
NSArray *AriveATime = [FlightStatus valueForKey:@"arrivalDate"];
NSString *DepartTimeString = [DepartATime valueForKey:@"dateLocal"];
NSString *ArriveTimeString = [AriveATime valueForKey:@"dateUtc"];
NSArray *Delays = [FlightStatus valueForKey:@"delays"];
NSString *DepartDelayMinutes = [Delays valueForKey:@"departureGateDelayMinutes"];
NSString *ArriveDelayMinutes = [Delays valueForKey:@"arrivalGateDelayMinutes"];
NSArray *AirportInfo = [FlightStatus valueForKey:@"airportResources"];
NSString *DepartTerminal = [AirportInfo valueForKey:@"departureTerminal"];
NSString *DepartAGate = [AirportInfo valueForKey:@"departureGate"];
NSString *ArriveTerminal = [AirportInfo valueForKey:@"arrivalTerminal"];
NSString *ArriveAGate = [AirportInfo valueForKey:@"arrivalGate"];
NSString *BaggageClaim = [AirportInfo valueForKey:@"baggage"];
flightID.text=FlightID;
DepartCode.text=DepartACode;
ArrivalCode.text=ArivalACode;
DepartTime.text=DepartTimeString;
ArriveTime.text=ArriveTimeString;
DepartDelay.text=DepartDelayMinutes;
ArriveDelay.text=ArriveDelayMinutes;
DepartTerm.text=DepartTerminal;
DepartGate.text=DepartAGate;
ArriveTerm.text=ArriveTerminal;
ArriveGate.text=ArriveAGate;
Baggage.text=BaggageClaim;
当我运行它时,我收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x8aa85f0'
不,我不是想将数组的值分配给字符串。所以我在这里很困惑。
想法?
谢谢!