Most likely a rather trivial question but will the completion block always be called using [NSURLConnection sendAsynchronousRequest: ...]
? OR do I have to implement a timeout timer?
Consider the following where I add a MBProgressView
before the call and remove it ONLY in the completion block:
[self showHUDWithTitle:@"Configuring"];
[NSURLConnection sendAsynchronousRequest:request
queue:[[NSOperationQueue alloc] init]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error) {
if ([data length] >0 && error == nil) {
[self hideHUDWithFlag:YES
andTitle:@"Finished"
andSubtitle:@"(Box was configured)"];
} else if ([data length] == 0 && error == nil) {
[self hideHUDWithFlag:NO
andTitle:@"Failed"
andSubtitle:@"(Check box connection)"];
NSLog(@"Nothing was downloaded.");
} else if (error != nil) {
[self hideHUDWithFlag:NO
andTitle:@"Error"
andSubtitle:@"(Check box connection)"];
NSLog(@"Error = %@", error);
}
}];