danie1s / tiercel Goto Github PK
View Code? Open in Web Editor NEW简单易用、功能丰富的纯 Swift 下载框架
License: MIT License
简单易用、功能丰富的纯 Swift 下载框架
License: MIT License
公司的工程是OC写的,有对应的OC框架吗?
计算的下载完成时间比实际时间大了8小时
eg:实际 11:04 完成,计算获得时间为 19:04
看了下代码,似乎是转换时间时增加 3600 * 8 导致的,去掉后正常
public func convertTimeToDateString() -> String {
// 此处为何要加 3600 * 8?
let time = base + 3600 * 8
let date = Date(timeIntervalSince1970: time)
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
return formatter.string(from: date)
}
好
pod 后的代码, 与 demo 的不一致
查看 demo 能运行,
pod 到项目里后,
TRManager 并没有 default 属性
如题 , 回调回来是 TRTask , 不能直接回来download task吗? 而且, success 不应该是下载成功的回调吗? 我看demo中, 还在success 里判断status? 其他任何状态都应该是 faild回调呀
Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks
我之前一般是使用suspend暂停,然后resume恢复。
如果出错调用了 didCompleteWithError,我再获取resumeData重新创建下载。
suspend 相比 cancelByProducingResumeData 有其他的什么坑吗,之前没遇到过。
suspend一般手动kill app 就会调用 didCompleteWithError。
用tableView的代理方法,commiteditingStyle删除cell的时候,会出现其它cell不更新状态的情况
这种命名方式是 OC 语言风格的产物,Swift 中都是按模块划分的,移除更 swifty 。
使用时,已经有 tr
了,所以更不需要这样的命名风格。
建议考虑一下。
api:http://120.76.240.104:8017/api/course/get_ppt_content?courseId=78&token=23812ba3-8df9-417c-a2af-9915b0773088
/api/course/get_ppt_content: 是通过php header头下载文件
courseId:表示是不同的文件
使用后文件不能区分:都是保存一个名get_ppt_content的文件
状态码不应该只有200才算成功吧, 断点续传有些返回的是206 , 建议设置成200-209
您好 下载您的demo示例打包之后显示的错误为:
Undefined symbols for architecture armv7:
"protocol witness table for __ObjC.UIDevice : Tiercel.TiercelCompatible in Tiercel", referenced from:
Demo.BaseViewController.viewDidLoad() -> () in BaseViewController.o
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
function signature specialization <Arg[0] = Owned To Guaranteed> of Demo.ViewController1.(updateUI in _5C5E94575650EAFC2B93D94793CAD274)(Tiercel.TRTask) -> () in ViewController1.o
麻烦可以看一下吗?谢谢
我在A页面添加一个下载, 在B页面又添加一个下载, 在C页面也添加一个下载.
我可以在某一处统一的拿到所有下载成功后的回调吗?
iPhone system - iOS10.3
moveItem error: Error Domain=NSCocoaErrorDomain Code=516 "“CFNetworkDownload_J1VtL6.tmp” couldn’t be moved to “OM
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x131d38b10 of class __NSCFBackgroundDownloadTask was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x1744344c0> (
<NSKeyValueObservance 0x174056b60: Observer: 0x131d07ab0, Key path: currentRequest, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x174653f50>
问题1:下载的任务是大量小的且有依赖性的,例:A>B>C>D; 创建后台下载任务A,当A任务在后台完成下载后,是否可以创建新的后台下载任务B? (尝试这样做后发现新的后台下载任务B启动下载的时机不确定,不是立刻而是一段时间后)。
问题2:如果不可以后台下载完成后再创建新的后台任务,那么在前台时需要把所有的后台下载任务先创建出来,上限是多少?
下载webp格式的图片下载下来后无法打开
怎么通过下载链接获取上一次下载文件的状态和下载进度
下载demo查看下载功能,单个文件下载,将url替换成本地的,下载正常,但是task.progress.totalUnitCount = -1
应该对response的statuscode进行处理,目前添加了一个404的处理如下:
TRDownloadTask.swift文件下196行加入:
if response.statusCode == 404 {
completed()
manager?.completed()
completionHandler(.cancel)
return
}
望完善对应的statuscode处理
下载结果会回调两次
rt
打包出错:
Undefined symbols for architecture arm64:
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
大神这个不支持arm64吗?
真机提示这个错误
Undefined symbols for architecture arm64:
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
麻烦大佬看一下
析构一个 TRManager 后重新创建,会导致这个崩溃,我想在不同用户下创建不同的 TRManager。
比如创建目录, 删除缓存等等, 其他的不列举了.
Swift 类默认给了 throws
. 应该最好不要忽略掉那些错误, 有时候可能正是那些莫名的错误导致功能异常, 而没有暴露给外部去处理. 作为一个第三方库, 不太合理
Swift 4,Cocoapods 集成环境下
'tr' is inaccessible due to 'internal' protection level
public class TRSessionDelegate: NSObject {
public weak var manager: TRManager?
}
此处是否应该用weak来修饰manager? 不然会造成循环引用,请追查一下。
public var configuration = TRConfiguration() { didSet { guard !shouldCreatSession else { return } shouldCreatSession = true if status == .running { runningTasks = tasks.filter { $0.status == .running } waitingTasks = tasks.filter { $0.status == .waiting } totalSuspend() } else { session.invalidateAndCancel() } } }
对 configuration 赋值后,就没有机会创建新的 session,也就不能创建任务了吧
现在的 remove 只是删除了任务 并没有清除这个下载的缓存. 需要彻底的删除,谢谢
不支持oc调用
Cache.swift
public func fileExists(fileName: String) -> Bool {
guard let path = filePath(fileName: fileName) else { return false }
return fileManager.fileExists(atPath: path)
}
这里判断文件用 fileExists 返回是true但文件打不开(下载的图片在File中显示为0B 且打不开但是显示下载成功)
建议用 isExecutableFile 判断
如题,运行的是demo工程,真机7plus,11.3
如果自己不指定文件名,应该使用 suggestedFilename
比如我通过此链接下载仓库
https://codeload.github.com/Danie1s/Tiercel/zip/master
如果不指定文件名,默认都是路径最后一段,类似在GitHub 下载源码,文件名将全部成为 master, 并且不能很方便到指定它是什么类型(zip)。
首先非常感谢大佬开源这个下载器源码。
看到源码中多处都是使用遍历匹配的方式来获取task,感觉换成字典性能应该会好很多。(强迫症)
或者说这样写是出于怎样的考虑呢?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.