Swift 工具库 Transporter

码农软件 · 软件分类 · 其他开发相关 · 2019-10-21 09:12:36

软件介绍

Transporter 是一个方便上传和下载的库。

特性

  • 支持并发或者顺序上传或者下载多个文件

  • 支持后台上传和下载

  • 支持进程跟踪 (单个任务或者任务组)

  • 支持重置,停止,取消,重试任务

  • header 可配置

  • 请求参数可配置

快速示例

let path = NSBundle.mainBundle().pathForResource("bigfile", ofType: "zip")let fileUrl = NSURL(fileURLWithPath: path!)!let task = UploadTask(url: "http://server.com", file: fileUrl)    .progress { sent, total in
        let per = Double(sent) / Double(total)
        println("uploading: \(per)")
    }    .completed { response, json, error in
        println("completed")
    }


 Transporter.add(task1 <--> task2 <--> task3)                     // concurrent tasks
            .progress { bytes, total in
                let per = Double(bytes) / Double(total)
                println("concurrent tasks: \(per)")
            }            .completed { alltasks in
                println("task1, task2, task3: completed")
            }            .add(task4 --> task5 --> task6)                       // serial tasks 
            .progress { bytes, total in
                println("serial tasks")
            }            .resume()

用法

// downloading tasklet task = DownloadTask(url: downloadUrl, destination: des)    .progress { bytes, total in
        let per = Double(bytes) / Double(total)
        println("downloading: \(per)")
    }    .completed { response, _, error in
        println("completed")
    }// uploading task// upload types: File, Data, Streamlet task = UploadTask(url: "http://server.com", data: uploadData)    .progress { sent, total in
        let per = Double(sent) / Double(total)
        println("uploading: \(per)")
    }    .completed { response, json, error in
        println("completed")
    }// tasktask.headers = ["key": "value"]
task.params = ["key": "value"]
task.pause()
task.cancel()
task.retry// background handling// add the following method in the app delegatefunc application(application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: () -> Void) {
    Transporter.handleEventsForBackgroundURLSection(identifier, completionHandler: completionHandler)
}// Transporter configurationsTransporter.headers = [key: value]
Transporter.timeoutIntervalForRequest = 30.0Transporter.timeoutIntervalForResource = 24 * 60 * 60.0Transporter.HTTPMaximumconnectionsPerHost = 5

本文地址:https://www.codercto.com/soft/d/17225.html

游戏化革命:未来商业模式的驱动力

游戏化革命:未来商业模式的驱动力

[美]盖布·兹彻曼、[美]乔斯琳·林德 / 应皓 / 中国人民大学出版社有限公司 / 2014-8-1 / CNY 59.00

第一本植入游戏化理念、实现APP互动的游戏化商业图书 游戏化与商业的大融合、游戏化驱动未来商业革命的权威之作 作者被公认为“游戏界的天才”,具有很高的知名度 亚马逊五星级图书 本书观点新颖,游戏化正成为最热门的商业新策略 游戏化是当今最热门的商业新策略,它能帮助龙头企业创造出前所未有的客户和员工的参与度。商业游戏化策略通过利用从游戏设计、忠诚度计划和行为经济学中所汲取......一起来看看 《游戏化革命:未来商业模式的驱动力》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试