使用来自iPhone的线程进行HTTP请求 [英] HTTP request using threading from iphone

查看:64
本文介绍了使用来自iPhone的线程进行HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能指出解释穿线的花絮吗?在我的应用程序中,我正在将一些数据(甚至是大尺寸的图像)上传到Servlet.通常,取决于带宽,上载过程可能会花费相当长的时间.因此,我需要在其中实现线程,以便上传过程在后台进行.这里的任何专家都可以发布示例或教程链接或类似内容. 预先感谢.

Can anyone point out a turorial which explains threading?? In my application, i'm uploading some data (even large sized images) to the servelet. The uploading process may take quite a large time depending on the bandwidth, as usual. So i need to implement threading in it so that the uploading process takes place in the background. Any experts here, may please post an example or a tutorial link or something like that. Thanks in advance.

推荐答案

启动后台任务的一种非常简单而强大的方法是使用

A very simple and robust way of launching background tasks is using NSOperation and NSOperationQueue. It allows you to create a class (inherited from NSOperation) that represents a task which can be placed in a threaded queue which is handled in the background.

NSOperationQueue文档

另一种在后台启动内容的简便方法是使用 performSelectorInBackground 方法:

Another easy way of launching something in the background is by using the performSelectorInBackground method:

- (void) launchTask {
   [self performSelectorInBackground:@selector(backgroundTask) withObject:nil];
}

- (void) backgroundTask {
   // stuff to do in background
}

这篇关于使用来自iPhone的线程进行HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆