Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x7f9298554560'
- Printing description of self->metArray:
- {
- weatherObservation = {
- ICAO = YBBN;
- clouds = "few clouds";
- cloudsCode = FEW;
- countryCode = AU;
- datetime = "2014-11-24 03:00:00";
- dewPoint = 20;
- elevation = 5;
- hectoPascAltimeter = 1014;
- humidity = 61;
- lat = "-27.38333333333333";
- lng = "153.1333333333333";
- observation = "YBBN 240300Z 02019KT 9999 FEW029 SCT250 28/20 Q1014";
- stationName = "Brisbane Airport M. O";
- temperature = 28;
- weatherCondition = "n/a";
- windDirection = 20;
- windSpeed = 19;
- };
- }
- -(void)getMetar{
- // NSString *location = @"YBBN";
- NSString * const metarUrl =@"http://api.geonames.org/weatherIcaoJSON?ICAO=YBBN&username=demo";
- NSURL *url2 = [NSURL URLWithString:metarUrl];
- NSData *data2 = [NSData dataWithContentsOfURL:url2];
- metArray = [NSJSONSerialization JSONObjectWithData:data2 options:kNilOptions error:nil];
- //Create an NSDictionary for the weather data to be stored.
- NSDictionary *metarJson = [NSJSONSerialization JSONObjectWithData:data2 options:kNilOptions error:nil];
- //Loop through the JSON array
- NSArray *currentMetarArray = metarJson[@"weatherObservation"];
- //set up array and json call
- metarArray = [[NSMutableArray alloc]init];
- for (NSDictionary *metaritem in currentMetarArray)
- {
- //create our object
- NSString *nClouds = [metaritem objectForKey:@"clouds"];
- NSString *nObservation = [metaritem objectForKey:@"observation"];
- //Add the object to our animal array
- [metarArray addObject:[[metar alloc]initWithclouds:(nClouds) andobservation:nObservation]];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement