Here is my parsing code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
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;
}
When I run that, it gives me this:
2013-02-09 21:51:40.262 Places[7083:c07] -[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x8262b50 2013-02-09 21:51:40.263 Places[7083:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x8262b50'
And highlights this:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Does my code look bad or can someone at least explain what this error might mean?
Here is what I'm working with. http://pastebin.com/vv8ScBfZ
I'm sorry I am very new to all this.
Thanks for any tips!
FlightStatus
is anNSArray
, but then you're trying to retrieve individualNSString
values from this array usingvalueForKey
. IfFlightStatus
was an array of dictionaries, thenvalueForKey
would return an array of values, not an individualNSString
. And your error message would seem to confirm this, because it's telling you that you retrieved aNSArray
at some point and you're trying to use it as aNSString
. – Rob