Ryu*_*lio 8 xcode background swift apple-watch-complication watchos-4
我在模拟器上的WatchOS4中制作URLBGTask时遇到的这个错误是什么?
2017-09-28 16:05:26.452999+0900 MiFollowers WatchKit Extension[4628:4012814] [bg_app_refresh] -[WKRefreshBackgroundTask cleanupStorage]_block_invoke:213: Error attempting to reach file:///Users/ryuuzaki/Library/Developer/CoreSimulator/Devices/2E4D6389-93B7-4542-B07F-9A02C720B9AF/data/Containers/Data/PluginKitPlugin/FA4415DF-D984-4394-80B9-EDA199AB587E/Library/com.apple.watchkit/bktaskapp_(null): Error Domain=NSCocoaErrorDomain Code=260 "The file “bktaskapp_(null)” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/ryuuzaki/Library/Developer/CoreSimulator/Devices/2E4D6389-93B7-4542-B07F-9A02C720B9AF/data/Containers/Data/PluginKitPlugin/FA4415DF-D984-4394-80B9-EDA199AB587E/Library/com.apple.watchkit/bktaskapp_(null), NSFilePath=/Users/ryuuzaki/Library/Developer/CoreSimulator/Devices/2E4D6389-93B7-4542-B07F-9A02C720B9AF/data/Containers/Data/PluginKitPlugin/FA4415DF-D984-4394-80B9-EDA199AB587E/Library/com.apple.watchkit/bktaskapp_(null), NSUnderlyingError=0x79b0e340 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
你们中任何一个聪明的人都知道这一切意味着什么?
我也得到了这个.最近两天开车送我疯了.
我仍然不确定是否要求您使用该userInfo属性是一个错误或"功能" .如果您没有userInfo从方法中的后台刷新任务获取属性,则会发生这种情况handle(_ backgroundTasks).任何访问属性的工作.解决错误的一个简单的解决handle方法是backgroundTask.userInfo在userInfo:参数中安排下一次背景刷新,该参数只是继续分配nil给下一个任务.
WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: refreshDate, userInfo: backgroundTask.userInfo) { (error) in
if let error = error {
print ("Background task error:\(error.localizedDescription)")
}
}
Run Code Online (Sandbox Code Playgroud)
当然,这种解决方法意味着您将无法使用userInfo.更好的代码可能是在那里粘贴一些东西,例如调度日期或任务的标识符,或[String:Any]两者的字典.
| 归档时间: |
|
| 查看次数: |
632 次 |
| 最近记录: |