IOS 有没有办法发送网页请求并在 iphone ios 上忘记它?
我想从我的应用程序向 www.test.com/updateMySqlTables.php
发送一个电话,但我不想等待该过程完成。
像这样的电话
NSString *checkReturn = [NSString stringWithContentsOfURL:checkURL]
但不想等待返回。我希望我的服务器在后台清理表中的所有旧日期。
I want to send a call to lets say www.test.com/updateMySqlTables.php
from my app but i dont want to wait around for the proccess to complete.
something like this call
NSString *checkReturn = [NSString stringWithContentsOfURL:checkURL]
But don't want to wait for the return. I want my server to cleanup any old dates in table in the background.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为您需要的只是启动一个异步请求并实现其相应的 requestDidDeceiveData: 方法和 requestDidFinish: 方法,并将这两个方法留空,因为您不关心请求可能生成的任何响应。由于它是异步的,因此它会自动在后台运行。您的应用程序的主线程不会受到影响。
iOS SDK 有自己的方式来发送异步请求。您还可以考虑使用更著名的 ASIHTTPRequest 包来完成您的工作,这更容易设置和监控。
I think all you need is start an asynchronous request and implement its corresponding requestDidDeceiveData: method and requestDidFinish: method, and leave these two methods blank, since you don't care about any response the request might generate. Since it's an asynchronous one, it'll automatically run in the background. Your app's main thread won't be affected.
iOS SDK has its own way to post an asynchronous request. you can also consider to use a more famous ASIHTTPRequest package to do your job, which is easier to setup and monitor.
是的。加载请求:
并确保添加将在成功/错误时调用的适当委托方法:
Yes. Load the request:
And be sure to add the appropriate delegate method(s) that will be called on success/error:
一种方法是使用 PerformSelectorInBackground:withObject: 或 [NSThread detachNewThreadSelector:toTarget:withObject:] 在后台线程中加载信息。两者都需要您创建一个新方法来加载数据。
One way would be to load your information in a background thread, using performSelectorInBackground:withObject: or [NSThread detachNewThreadSelector:toTarget:withObject:]. Both would require you to create a new method to load the data.
好的,现在 php 标签已被删除,我的答案不再是相对的。
窃取自:http://andrewensley.com/2009/06 /php-redirect-and- continue-without-abort/
Ok, now that php tag was removed, my answer is not relative anymore.
stolen from: http://andrewensley.com/2009/06/php-redirect-and-continue-without-abort/
我知道在 Linux 中可以在后台运行 php 脚本。
我猜想在某些配置中使用 exec 可能会受到限制。
它在后台运行 php 脚本 (&) 并将 sneds 输出到无处 (/dev/null)
I know that in Linux it is possible to run a php script in the background.
I guess there may be a restriction on using exec in some configurations.
Which runs the php script in the background (&) and sneds output to nowhere (/dev/null)