【发布时间】:2018-01-28 17:32:01
【问题描述】:
我有一个带有 URLSession 代表的课程。我打算将它与后台配置一起使用。我知道当某个事件发生时会调用处理程序,例如didFinishDownloadingTo。
但是,我的 ExtensionDelegate 类中确实有 handle 函数:
func handle( _ handleBackgroundTasks:
Set<WKRefreshBackgroundTask>)
// Sent when the system needs to launch the application in the background
to process tasks. Tasks arrive in a set, so loop through and process each one.
for task in handleBackgroundTasks {
switch task {
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
我想知道:我应该在哪里处理下载后收到的数据?在 didFinishDownloadingTo 或我的 ExtensionDelegate 类的那个函数上,在 switch 语句的适当情况下?
同一周期的另一个问题:我到处阅读,在完成后台任务后必须记住setTaskCompleted()。但是我在其他地方读到,如果计划的数据传输尚未完成,则不应将任务设置为已完成。我该如何检查?
【问题讨论】:
标签: watchkit watchos watchos-4