Reputation:
I'm trying to call a REST Api using NSUrlSession but it's not being called.
- (void)generateData {
NSURL *url = [NSURL URLWithString:@"http://rest-service.guides.spring.io/greeting"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data,NSURLResponse *response,NSError *error){
NSLog(@"Flying");
}];
}
My NSLog is never printed and the internet on emulator is working because i'm using Auth0 to authenticate.
Any idea?
Upvotes: 0
Views: 63
Reputation: 12254
You need to call resume
on your task in order to start it.
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data,NSURLResponse *response,NSError *error){
NSLog(@"Flying");
}] resume];
Upvotes: 1