我需要在没有任何过滤的情况下查询所有的记录类型,。我尝试了两种方法:
let query = CKQuery(recordType: "Pm", predicate: nil)
let query = CKQuery(recordType: "Pm", predicate: NSPredicate(format: ""))我收到错误:
'NSInvalidArgumentException',原因:‘无法解析格式字符串""’
怎么办?
发布于 2014-07-08 11:28:31
你不能在没有谓词的情况下执行查询,但NSPredicate确实有一个专门用于此的方法,在Swift中,它是通过初始化器使用的:
init(value: Bool) -> NSPredicate // return predicates that always evaluate to true/false使用方法如下所示。
let predicate = NSPredicate(value: true)发布于 2014-07-08 07:02:49
要获取所有记录,您需要使用以下内容作为CKQuery的谓词:
[NSPredicate predicateWithFormat:@"TRUEPREDICATE"]或者,在Swift中:
NSPredicate(format: "TRUEPREDICATE")这实际上就像没有任何谓词一样。
https://stackoverflow.com/questions/24620083
复制相似问题