NSString *cityString = [@"南京" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *weatherString = [NSString stringWithFormat:@"http://v.juhe.cn/weather/index?cityname=%@&key=%@",cityString,@"申请的Key"];
NSURL *weatherUrl = [NSURL URLWithString:weatherString];
NSMutableURLRequest *weatherUrlRequest = [[NSMutableURLRequest alloc]initWithURL:weatherUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10];
[NSURLConnection sendAsynchronousRequest:weatherUrlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *respone, NSData *data, NSError *error){
if (!error) {
NSDictionary *weatherDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSLog(@"相应数据为:%@",weatherDict);
} else {
NSLog(@"响应数据error");
}
}];