請看下面的代碼:如何爲NSURLConnection請求設置實時超時?
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:<...> cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:3.0];
<...>
[NSURLConnection sendSynchronousRequest:request returningResponse:&WSresponse error:&WSerror]
此代碼波紋管是由後臺線程調用:
[self performSelectorInBackground:@selector(<...>) withObject:nil];
有時sendSynchronousRequest的效果要大於3.0秒。 (最多1分鐘)。
- 如何設置實時超時而不是工作
timeoutInterval:3.0
? - 如何添加一個用戶在任何時候停止凍結的能力
NSURLConnection
取消按鈕的請求?
非常感謝您的幫助!
提醒:ASIHTTPRequest未得到積極維護 –