停止当前的NSURLConnection [英] Stop current NSURLConnection
本文介绍了停止当前的NSURLConnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,每当 mySearchBar.text
更改时,我正在制作 NSURLConnection
。我遇到一个问题,如果用户输入的文字过快, respondData
就会被破坏。
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.
所以,我想知道有没有办法检查是否仍然加载相同的 NSURLConnection
?如果是,我如何删除当前连接并开始新连接?
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?
推荐答案
为NSURLConnection添加属性并在开始之前新连接,执行:
Add a property for that NSURLConnection and before starting new connection, do:
[self.conn cancel];
self.conn = nil;
这篇关于停止当前的NSURLConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文