很可能是一个相当微不足道的问题,但完成块是否总是被调用[NSURLConnection sendAsynchronousRequest: ...]
?或者我必须实现一个超时计时器吗?
考虑以下我MBProgressView
在调用之前添加 a 并仅在完成块中将其删除的情况:
[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);
}
}];