查询系统字段时出现CKError:拒绝了“未知字段'createdAt'”

Bfr*_*omG 2 cloudkit ckquery

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

query.sortDescriptors = [NSSortDescriptor(key: "createdAt", ascending: false)]
Run Code Online (Sandbox Code Playgroud)

并得到以下错误:

CKError 0x1c4447fb0:“无效的参数”(12/2018); 服务器消息=“未知字段'createdAt'”;uuid = 9C450848-2449-4892-93BC-C46363203042; 容器ID =“ ...

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

Bri*_*amm 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.
Run Code Online (Sandbox Code Playgroud)

  • @DanielBrower Meta 字段值应作为属性访问。尝试`myRecord.creationDate` (2认同)
  • 哇,这太荒谬了..为什么在仪表板中我看到“modifiedAt”并将其设置为“sortable”,然后我必须使用“modificationDate”?!顺便说一句,谢谢你解决了这个问题。 (2认同)