Cloudkit:CKDatabaseOperation 不适用于蜂窝网络
Posted
技术标签:
【中文标题】Cloudkit:CKDatabaseOperation 不适用于蜂窝网络【英文标题】:Cloudkit: CKDatabaseOperation not working on cellular 【发布时间】:2015-12-09 21:36:55 【问题描述】:大家好CloudKit
用户:
我花了很长时间试图找出CKDatabaseOperation
不提供任何反馈的原因。在手机上保存CKRecords
时没有错误,没有回调。
您能告诉我您对此有何看法吗?
【问题讨论】:
ios 9 CloudKit: query does not return anything while connected to cellular network的可能重复 【参考方案1】:Apple 开发者论坛中有人找到了解决方案: 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 不适用于蜂窝网络的主要内容,如果未能解决你的问题,请参考以下文章
cloudKit:公共数据库中的 CKFetchRecordChangesOperation