最有可能是一個相當微不足道的問題,但完成塊將始終使用[NSURLConnection sendAsynchronousRequest: ...]
調用?或者我是否必須實現超時定時器?[NSURLConnection sendAsynchronousRequest:...]總是發送完成塊嗎?
考慮下面的,我的電話之前加MBProgressView
並刪除它,只有在完成塊:
[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);
}
}];
自然。完成處理程序是COMPLETION處理程序 - 不是成功處理程序:D – 2013-03-20 08:55:28
@ Daij-Djan我是成功處理程序,而不是完成完成的完成程序! – Groot 2013-03-20 09:05:06
if(!error)= success:D – 2013-03-20 09:12:08