I am trying to utilize CloudKit
in my iOS application, but when I attempt to create a new record for for a User
record type (record type is named
Users is a special recordType that already exist in CloudKit. You should not create records yourself. Records will be automatically created for new users that are using your app. You also can't create subscriptions and query the Users recordtype. You can only query Users records directly by ID. You can store extra data in the Users recordType, but I think in your case it would be better if you named your record type something else.
In addition to Edwin's answer, it's entirely feasible to save custom fields to the public Users
recordType, but you need to retrieve the CKRecordID
for the user first (via CKContainer
fetchUserRecordID()
or discoverUserIdentity()
) and then build the CKRecord
on Users
using that ID.
Also, if you're using CKModifyRecordsOperation
make sure the savePolicy
is set to .changedKeys
in order to allow the update to go through.