xcode 如何使用 NSURLRequest / NSURLConnection 将 mp3 文件下载到应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2204010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:16:06  来源:igfitidea点击:

How to use NSURLRequest / NSURLConnection to download an mp3 file to app?

iphonexcodensurlconnectionnsurlrequest

提问by RexOnRoids

The Situation
In my app, I am currently downloading an mp3 file (to docs directory) using [NSData dataWithContentsOfURL:URL], a method that works fine, but ties down the CPU, dissallowing screen updates of download status. So, I want to download using a different method so that I can update the screen WHILEdownloading to alert the user that the download has begun.

情况
在我的应用程序中,我目前正在使用 下载一个 mp3 文件(到 docs 目录)[NSData dataWithContentsOfURL:URL],这是一种工作正常的方法,但会占用 CPU,不允许屏幕更新下载状态。所以,我想用不同的方法,这样我可以更新屏幕下载WHILE下载到提醒用户下载已经开始。

Question
How do I set up my viewController to use NSURLRequestorNSURLConnectionto download an mp3 file? (please give source)

问题
如何设置我的 viewController 以使用NSURLRequestNSURLConnection下载 mp3 文件?(请注明出处)

回答by Jordan

Use "NSURLConnection asynchronously" search for the term and you'll find source. Or just NSURLConnection.

使用“NSURLConnection asynchronously”搜索该术语,您将找到来源。或者只是 NSURLConnection。

For example:

例如:

NSURLConnection NSURLRequest proxy for asynchronous web service calls

用于异步 Web 服务调用的 NSURLConnection NSURLRequest 代理