2011-12-17 23 views
2
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.urlString]]; 
     NSURLConnection *con = [[NSURLConnection alloc] 
           initWithRequest:req 
           delegate:self 
           startImmediately:NO]; 
     [con scheduleInRunLoop:[NSRunLoop currentRunLoop] 
         forMode:NSRunLoopCommonModes]; 
     [con start]; 

     if (con) { 

      self.receivedData=[[NSMutableData alloc] init]; 

     } else { 

      ... 
     } 
     [req release]; 

使用此代碼,我正在下載圖像。如何在下載過程中停止/關閉NSLURLConnection

如何在下載過程中停止下載並關閉連接?

回答

2

NSURLConnection有一個-cancel方法。

希望有幫助!

+0

謝謝。你非常幫助我 – mrde 2011-12-17 12:52:05

相關問題