2012-04-12 183 views
0

我使用ASIHTTP請求來訪問web html頁面。取消ASIHTTP請求

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:requestURL]]; 
[request setTag:selectTag]; 
[request setDownloadCache:[ASIDownloadCache sharedCache]]; 
[request setCachePolicy:ASIAskServerIfModifiedCachePolicy | ASIFallbackToCacheIfLoadFailsCachePolicy]; 
[request setCachePolicy:ASIOnlyLoadIfNotCachedCachePolicy]; 
[request setDelegate:self]; 


[request startAsynchronous]; 

如果我從ViewController導航到另一個。

是否有可能取消這個異步http請求,如果它還沒有觸發'requestFinished'?

歡迎任何評論

回答

0

下面的方法目前有ASIHttpRequest,你可以用它來取消請求 -

- (void)cancel { 
     [self performSelector:@selector(cancelOnRequestThread) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];  
} 

您可以調用該方法 -

[request cancel];