iOS开源:SRDownloadManager-文件下载管理
FilomenaOGZ
8年前
<h2>SRDownloadManager</h2> <h2>Features</h2> <ul> <li>Provide download status callback, download progress callback, download complete callback.</li> <li>Support multi-task at the same time to download.</li> <li>Support breakpoint download even exit the App.</li> <li>Support to delete the specified file by URL and clear all files that have been downloaded.</li> <li>Support customize the directory where the downloaded files are saved.</li> </ul> <ul> <li>提供下载状态回调, 下载进度回调, 下载完成回调.</li> <li>支持多任务同时下载.</li> <li>支持断点下载, 即使退出重启 App.</li> <li>支持通过 URL 删除指定文件和清除所有已下载的文件.</li> <li>支持自定义保存下载文件的目录.</li> </ul> <h2>Show</h2> <p style="text-align:center"><img src="https://simg.open-open.com/show/2753a9872b9bf923d84430dd13ef4ea0.png"></p> <h2>Installation</h2> <p>Drag the <strong>SRDownloadManager</strong> folder to the project.</p> <h2>Usage</h2> <pre> <code class="language-objectivec">[[SRDownloadManager sharedManager] downloadFile:fileURL state:^(SRDownloadState state) { // Called when download state changed. } progress:^(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress) { // Called when download receive data every time. } completion:^(BOOL isSuccess, NSString *filePath, NSError *error) { // Called when download finished with success or error. }];</code></pre> <h2>APIs</h2> <pre> <code class="language-objectivec">/** The directory where the downloaded files are saved, default is .../Library/Caches/SRDownloadManager if not setted. */ @property (nonatomic, copy) NSString *downloadedFilesDirectory; + (instancetype)sharedManager; - (void)downloadFile:(NSURL *)URL state:(void (^)(SRDownloadState state))state progress:(void (^)(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress))progress completion:(void (^)(BOOL isSuccess, NSString *filePath, NSError *error))completion; - (BOOL)isDownloadFileCompleted:(NSURL *)URL; - (NSString *)fileFullPath:(NSURL *)URL; - (CGFloat)fileDownloadedProgress:(NSURL *)URL; - (void)deleteFile:(NSURL *)URL; - (void)deleteAllFiles; - (void)suspendDownloadURL:(NSURL *)URL; - (void)suspendAllDownloads; - (void)resumeDownloadURL:(NSURL *)URL; - (void)resumeAllDownloads; - (void)cancelDownloadURL:(NSURL *)URL; - (void)cancelAllDownloads;</code></pre> <p>If you have any question, submit an issue or contact me.</p> <p>If this repo helps you, please give it a star.</p> <p>Have Fun.</p> <p> </p> <p> </p> <p> </p>