0
我有一個登錄視圖,用戶將用於登錄到我的應用程序。 我使用NSURLConnection Asynchrounous請求塊連接到我的Web服務並來回傳遞數據。iOS - NSURLConnection異步請求一次,然後失敗(掛起)第二次嘗試
我有一個奇怪的問題,如果用戶第一次登錄,它工作正常。但是,如果他們註銷,然後嘗試再次登錄請求發送,但從來沒有響應(我設置所有場景的alertviews;即超時,數據=無,錯誤!=零等)。它只是與我顯示的加載屏幕坐在那裏,並從不做任何事情。
我是否錯過了什麼?
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
if ([data length] > 0 && error == nil){
if(data != nil) {
//Handle Data Here
.............
} else {
[loadingView removeFromSuperview];
loadingView = nil;
BlockAlertView *alert = [BlockAlertView alertWithTitle:@"Network Error" message:@"Network connection was successful, but there was a problem with data transfer.\nPlease try again."];
[alert setCancelButtonWithTitle:@"OK" block:nil];
[alert show]; }
}
else if ([data length] == 0 && error == nil){
[loadingView removeFromSuperview];
loadingView = nil;
BlockAlertView *alert = [BlockAlertView alertWithTitle:@"Network Error" message:@"Network connection was successful, but there was a problem with data transfer.\nPlease try again."];
[alert setCancelButtonWithTitle:@"OK" block:nil];
[alert show];
}
else if (error != nil && error.code == NSURLErrorTimedOut){
[loadingView removeFromSuperview];
loadingView = nil;
BlockAlertView *alert = [BlockAlertView alertWithTitle:@"Network Error" message:@"The network request timed out.\nPlease check your internet connection and try again."];
[alert setCancelButtonWithTitle:@"OK" block:nil];
[alert show];
}
else if (error != nil){
[loadingView removeFromSuperview];
loadingView = nil;
BlockAlertView *alert = [BlockAlertView alertWithTitle:@"Network Error" message:@"There was a problem connecting to the network.\nPlease check your internet connection and try again."];
[alert setCancelButtonWithTitle:@"OK" block:nil];
[alert show];
}
}];