Swift - NSURLSession下载在后台? [英] Swift - NSURLSession downloading in background?

查看:142
本文介绍了Swift - NSURLSession下载在后台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用与$ code> AliExpress iOS应用程序相同的swift创建iOS应用程序。
这个应用程序有能力连接到我们的网站,并从JSON api在线下载所有的数据。
现在,我想从主页面的JSON api从我们的网站下载图标和横幅滑块的图片。但我不知道我能做什么我使用队列或背景功能,如在android中?另外,我是一个Android开发人员,我知道如何在Android中做到这一点。你也可以这样指导我。请引用我的示例代码或其逻辑描述。

解决方案

请参考以下链接了解



http://www.raywenderlich.com/51127/nsurlsession-tutorial



Apple文档可以在以下链接中找到



https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/ NSURLSession_class /



Swift示例可以在这里找到



http://jamesonquave.com/blog/making-a-post-request-in-swift/



我还创建了一个相同的演示文稿

https://github.com/Gagan5278/SessionDownload



如果您想了解更多信息,请告诉我。


I'm creating an iOS app by swift that is as same as the AliExpress iOS app. This App has ability that connect to our site and download all of data from JSON api online. Now, I wanna download the images of the icons and banner slider from our site by JSON api in main page. But I don't know how i can do it. Do I use queues or background functions like in android? Also, I'm an android developer and i know how i can do this in android. You can guide me by this way ,too. please guide me by sample codes or description of its logic.

解决方案

Please refer following link for tutorial

http://www.raywenderlich.com/51127/nsurlsession-tutorial

Apple documentation can be found on following link

https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSession_class/

Swift example can be found here

http://jamesonquave.com/blog/making-a-post-request-in-swift/

I have also created a demo for the same

https://github.com/Gagan5278/SessionDownload

Let me know if you want more on this.

这篇关于Swift - NSURLSession下载在后台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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