查询系统字段时的CKError:拒绝"未知字段' createdAt'"

时间:2018-04-19 21:44:44

标签: cloudkit ckquery

我正在对createdAt系统字段进行排序:

query.sortDescriptors = [NSSortDescriptor(key: "createdAt", ascending: false)]

并收到以下错误:

  

CKError 0x1c4447fb0:"无效的参数" (二千零一十八分之十二);服务器消息=   "未知字段' createdAt'&#34 ;; uuid =   9C450848-2449-4892-93BC-C46363203042;容器ID =" ...

我能够以这种方式查询和排序我创建的字段。与系统领域有什么不同? 该字段的索引是可排序和可查询的。

1 个答案:

答案 0 :(得分:5)

请使用creationDate作为密钥。 CK仪表板中的元键与用于查询的元键略有不同。这是一个元键列表:

recordID: CKRecordID
The unique ID of the record.

recordType: String
The app-defined string that identifies the type of the record.

creationDate: Date?
The time when the record was first saved to the server.

creatorUserRecordID: CKRecordID?
The ID of the user who created the record.

modificationDate: Date?
The time when the record was last saved to the server.

lastModifiedUserRecordID: CKRecordID?
The ID of the user who last modified the record.

recordChangeTag: String?
A string containing the server change token for the record.