Suppose I have a simple UIView class called 'ViewController' like this that access 'API' class for POST request.
@implementation ViewController
- (void)viewDidLoad {
api = [[API alloc] init];
[api postData];
}
@end
The API class will open the NSURLSession and post data
@implementation API
- (void)postData {
[[session dataTaskWithRequest:rq completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
// show Alert in ViewController if response code is 200
}] resume];
}
@end
How can I show a simple alert (or modify any UIView related objects) from the completionHandler in API class? I'm quite new in block concept. What is the best way to solve this?
Best regards.