Cloudkit:CKDatabaseOperation在蜂窝电话上不起作用 [英] Cloudkit: CKDatabaseOperation not working on cellular

查看:168
本文介绍了Cloudkit:CKDatabaseOperation在蜂窝电话上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向所有CloudKit用户致敬:

我经历了一段可怕的时间,试图找出为什么CKDatabaseOperation无法给出任何反馈.将CKRecords保存在移动电话上时,没有错误,没有回调.

I had a horrible time trying to find out why CKDatabaseOperation wouldn't give any feedback. No errors, no callbacks when saving CKRecords on cellular.

请让我知道您对此有何看法?

Could you please let me know what is your opinion regarding this?

推荐答案

Apple开发者论坛中的某人找到了一个解决方案: https://forums.developer.apple.com/thread/20047

Someone in the Developer Forums of Apple found a solution: https://forums.developer.apple.com/thread/20047

设置qualityOfService = .UserInitiated

示例:

let publicDB = CKContainer.defaultContainer().publicCloudDatabase    
let operation = CKModifyRecordsOperation(recordsToSave: [aRecord], recordIDsToDelete: nil)

operation.allowsCellularAccess = true
operation.qualityOfService = .UserInitiated // <----- THATS THE CELLULAR FIX

operation.perRecordProgressBlock = {(record, progress) in
    print("Progress: \(Int(progress*100.0))%")
}
operation.perRecordCompletionBlock = {(record, error) in
    print("Upload complete") //Add awesome error handling here
}
publicDB.addOperation(operation)

这篇关于Cloudkit:CKDatabaseOperation在蜂窝电话上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆