测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最新发布 | 2017年6月 |
由 redbearder 维护。
依赖 | |
EGOCache | ~> 2.0 |
AFNetworking | ~> 3.x |
##iOS下载管理器
###iOS的最简下载管理器
并行或顺序下载一组文件。
###它提供的内容
###动机
您是否想按并行或顺序下载一组图片,例如创建类似于Facebook时间轴单元格的单元格视图,该单元格包含多个图片。如果您尝试创建这样的东西,那么您就会意识到必须先下载一些图片,即时间轴单元格中的第一张图片必须在同一单元格的下一张图片之前被下载(记住我们在单元格中有多张图片)
IADownloadManager可以帮助您以并行顺序下载图片或任何其他文件。IASequentialDownloadManager可以帮助您按顺序下载一组URL。
###安装 ### 使用CocoaPods(推荐)
Podfile
pod 'IADownloadManager'
添加到PodfileApp.xcworkspace
####手动安装
CFNetwork.framework
和Security.framework
添加到项目中,如果您不确定如何添加框架,请阅读以下SO 答复###使用下载管理器,您应该具备以下先决条件
需要一个第三方(包含在项目的资源中)
###如何使用
每次下载操作都通过下载文件的NSURL进行标识,该NSURL是唯一的,并且会被缓存。
####使用代理回调按并行顺序下载文件。
开始下载操作
//Start the download operation, if the download operation is already started for this url,
//the urls will never be downloaded twice
[IADownloadManager downloadItemWithURL:url useCache:YES];
附加监听器
//Attach a listener to the url
[IADownloadManager attachListener:self toURL:url];
移除监听器
//Detach a listener to the url
[IADownloadManager detachListener:self];
代理方法
- (void)downloadManagerDidProgress:(float)progress;
- (void)downloadManagerDidFinish:(BOOL)success response:(id)response;
####使用代理回调按顺序下载文件。
开始下载操作
//Start the download operation, if the download operation is already started for these urls,
//the urls will never be downloaded twice
[IASequentialDownloadManager downloadItemWithURLs:urls useCache:YES];
附加监听器
//Attach a listener to the urls
[IASequentialDownloadManager attachListener:self toURLs:urls];
移除监听器
//Detach a listener to the url
[IASequentialDownloadManager detachListener:self];
代理方法
- (void)sequentialManagerProgress:(float)progress atIndex:(int)index;
- (void)sequentialManagerDidFinish:(BOOL)success response:(id)response atIndex:(int)index;
####基于块的回调。
还有一些用于通知下载事件的块,关于基于块的回调,请参考示例。