I have an NSURLSession that I use to load some data from the cloud. I use this call
[[session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (!error) {
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
if (httpResp.statusCode == 200) {
NSError *jsonError;
myArray = [[NSArray alloc] init];
myArray = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingAllowFragments
error:&jsonError];
}
}
}] resume];
Now some times I go through this and myArray is empty, so I want to know whether I can put a check inside that if myArray is empty retry to load the data!!