Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop current NSURLConnection

Currently, I am making an NSURLConnection whenever mySearchBar.text did change. I am experiencing an issue whereby if the user enters text too quickly, The respondData gets corrupted.

So, I was wondering is there a way to check whether the same NSURLConnection is still loading? If yes, How do I drop the current connection and start a new one?

like image 225
Gavin Avatar asked Aug 29 '11 11:08

Gavin


1 Answers

Add a property for that NSURLConnection and before starting new connection, do:

[self.conn cancel];
self.conn = nil;
like image 57
Filip Radelic Avatar answered Oct 22 '22 03:10

Filip Radelic