2010-09-16 77 views
0

我的iPhone應用程序使用了Web服務。應用程序訪問web服務以進行身份​​驗證。iPhone中的Web服務問題

我的問題是如何當親密用戶當服務器沒有發送任何響應時,它被稱爲。

ie..The控制不來

 

-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) response 
{ 
} 

+0

webservice使用哪種身份驗證方法? (基礎,摘要,Kerberos,...?) – VdesmedT 2010-09-16 13:53:57

回答

0

當您啓動登錄,也開始了NSTimer叫「無應答」的處理程序。事情是這樣的:

timeout = [NSDate dateWithTimeIntervalSinceNow:10.0]; 
timeoutTimer = [[NSTimer alloc] initWithFireDate:timeout interval:0 target:self selector:@selector(failLogin) userInfo:nil repeats:NO]; 
[[NSRunLoop currentRunLoop] addTimer:timeoutTimer forMode:NSDefaultRunLoopMode]; 
[loginUrlConnection start]; 

現在你需要一個failLogin方法殺死loginUrlConnection。當響應確實來臨時,請務必使定時器無效:

-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) response { 
    [timeoutTimer invalidate]; 
    /* Handle response... */ 
}