Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
- (IBAction)updateAction {
NSURLRequest* requestForWeatherData = [NSURLRequest requestWithURL:[NSURL URLWithString:@",UK&APPID=????????????"]];
//NOTE : ???? is here -> openweathermap api key write
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:requestForWeatherData completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
NSMutableDictionary *allData = [ NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
NSLog(@"%@ - Error %@", allData,error);
//data in serialized view
NSString* currentWeather = nil;
NSArray* weather = allData[@"weather"];
for (NSDictionary* weatherDictionary in weather) {
currentWeather = weatherDictionary[@"main"];
[self setImageAndTextWithWeather:currentWeather];
[dataTask resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.