取消发送同步请求
我有一个问题。
我需要取消最后一个 sendSynchronousRequest。用户推送一个字符,我发送新的请求,但我需要取消用户推送字符时的最后一个请求。
我的请求是:
NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest returnedResponse:&response error:&error];
感谢您的帮助。
祝你今天过得愉快!
I have a problem.
I need cancel the last sendSynchronousRequest. The user push a character and I send the new request, but I need that the last request when de user push a caracter are cancel.
My request are:
NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
Thank you for your help.
Have a nice day!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你无法取消它。
在执行连接和下载数据时,调用线程会被阻塞,因此您必须等待事情结束。
如果您需要在请求完成之前取消请求,则需要异步调用。
You can't cancel it.
The calling thread is blocked while the connection is performed and data is downloaded, so you'll have to wait things out.
If you need to cancel the request before it finishes, you need to make the call asynchronously.