NSURLSessionDataTask
-(void)getTheWeatherInformationOfLocation:(NSString*)location
{
NSString *stringUrl = [NSString stringWithFormat:@"https://api.seniverse.com/v3/weather/now.json?key=evhyrbftrsijy35v&location=%@&language=zh-Hans&unit=c",location];
NSURL * url = [NSURL URLWithString:stringUrl];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask * dataTask = [session dataTaskWithURL:url
completionHandler:^(NSData *data,
NSURLResponse *response,
NSError *error) {
myWeatherModel = [WeatherModel initWithDate:data];
[self performSelectorOnMainThread:@selector(showWeatherOfLocation) withObject:NULL waitUntilDone:YES];
NSLog(@"inside weather is %@",myWeatherModel.weather);
}];
[dataTask resume];
}
-(void)showWeatherOfLocation
{
self.location.text = location;
self.weather.text = myWeatherModel.weather;
self.viewWindow.text = myWeatherModel.name;
NSLog(@"outside weather is %@",myWeatherModel.weather);
[self.view reloadInputViews];
}