Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x7f9298554560'
  2.  
  3. Printing description of self->metArray:
  4. {
  5. weatherObservation = {
  6. ICAO = YBBN;
  7. clouds = "few clouds";
  8. cloudsCode = FEW;
  9. countryCode = AU;
  10. datetime = "2014-11-24 03:00:00";
  11. dewPoint = 20;
  12. elevation = 5;
  13. hectoPascAltimeter = 1014;
  14. humidity = 61;
  15. lat = "-27.38333333333333";
  16. lng = "153.1333333333333";
  17. observation = "YBBN 240300Z 02019KT 9999 FEW029 SCT250 28/20 Q1014";
  18. stationName = "Brisbane Airport M. O";
  19. temperature = 28;
  20. weatherCondition = "n/a";
  21. windDirection = 20;
  22. windSpeed = 19;
  23. };
  24. }
  25.  
  26. -(void)getMetar{
  27.  
  28. // NSString *location = @"YBBN";
  29. NSString * const metarUrl =@"http://api.geonames.org/weatherIcaoJSON?ICAO=YBBN&username=demo";
  30.  
  31. NSURL *url2 = [NSURL URLWithString:metarUrl];
  32. NSData *data2 = [NSData dataWithContentsOfURL:url2];
  33.  
  34. metArray = [NSJSONSerialization JSONObjectWithData:data2 options:kNilOptions error:nil];
  35.  
  36. //Create an NSDictionary for the weather data to be stored.
  37. NSDictionary *metarJson = [NSJSONSerialization JSONObjectWithData:data2 options:kNilOptions error:nil];
  38.  
  39. //Loop through the JSON array
  40. NSArray *currentMetarArray = metarJson[@"weatherObservation"];
  41.  
  42. //set up array and json call
  43. metarArray = [[NSMutableArray alloc]init];
  44. for (NSDictionary *metaritem in currentMetarArray)
  45. {
  46. //create our object
  47. NSString *nClouds = [metaritem objectForKey:@"clouds"];
  48. NSString *nObservation = [metaritem objectForKey:@"observation"];
  49.  
  50. //Add the object to our animal array
  51. [metarArray addObject:[[metar alloc]initWithclouds:(nClouds) andobservation:nObservation]];
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement