I have created a custom Network handler for managing all server calls from Application. This internally uses NSURLConnection and callback a function block once data fetch is complete. Current I can set the callback method or a callback CodeBlock. I wanted to understand which one is better and why.
OPTION 1 :
BaseNetworkHelper * helper = [[BaseNetworkHelper alloc] initWithURL:@"request/url/as/string" action:@"action/for/request" params:params];
[helper addFinishAction:self sel:@selector(markReadFinished:)];
is this way I get ARC warning when I call the callback method once action is complete. like bellow.
if (_target) {
if ([_target respondsToSelector:selector]) {
[_target performSelector:selector withObject:rdata];
}
}
OPTION 2:
BaseNetworkHelper * helper = [[BaseNetworkHelper alloc] initWithURL:@"request/url/as/string" action:@"action/for/request" params:params];
[helper startDownload:^(NSData *data, NSError *error) {
// Business logic for response handling / error handling
}];
Thanks.