0

Yahoo! Weather API

Hi, I just came over this site because I am trying to implement Yahoo! weather in my iPhone app I am using this code:

NSString * location =  @"Sunnyvale";
    NSString * address = @"http://weather.yahooapis.com/forecastxml?w=2502265&u=c";
    NSString * test = [NSString stringWithFormat:@"%@",address];
    NSURL * URL = [NSURL URLWithString:test];
    NSError * error;
    NSString* XML = [NSString stringWithContentsOfURL:URL encoding:NSASCIIStringEncoding error:&error];

    // Extract current temperature the 'dirty' way
    NSString * temp = [[[[XML componentsSeparatedByString:@"temp_c data=\""] objectAtIndex:1] componentsSeparatedByString:@"\""] objectAtIndex:0];
    NSLog(@"It's currently %@ degree in %@.", temp, location);

    NSString *text = (@"%@C am %@", temp, location);

but always when I am trying to build it my log say It's currently (null) degree in Sunnyvale. How can I get ride of this (null) and replace it with the Temperature and maby the condition (windy, foggy, snowy%u2026) Can anyone help me

by
  • G.
  • Jan 9, 2013
1 Reply

Recent Posts

in General Discussion at YDN