How to find CKRecords in iCloud that i created?

hi,

in my app, i have created and pushed CKRecords to the public database. others using the app have pushed CKRecords as well.

is there any way i can query iCloud for "all the CKRecords that i created?"

thanks,

DMG

Answered by DTS Engineer in 855592022

Every CKRecord has a creatorUserRecordID, and so you can use it to fetch the records with a certain user record ID:

let predicate = NSPredicate(format: "creatorUserRecordID == %@", yourUserRecordID)
let query = CKQuery(recordType: yourRecordType, predicate: predicate)

You can retrieve the user record ID of the current user using fetchUserRecordID(completionHandler:).

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

If adding a field to the database is an option, you can add a created by identifier and search for that.

Accepted Answer

Every CKRecord has a creatorUserRecordID, and so you can use it to fetch the records with a certain user record ID:

let predicate = NSPredicate(format: "creatorUserRecordID == %@", yourUserRecordID)
let query = CKQuery(recordType: yourRecordType, predicate: predicate)

You can retrieve the user record ID of the current user using fetchUserRecordID(completionHandler:).

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

thanks Ziqiao ... didn't remember about fetchUserRecord being available to get your user record.

and thanks to jlilest ... i had thought of this, but then i need a stabile ID within the app before uploading any CKRecords (a little too late for that, unfortunately).

How to find CKRecords in iCloud that i created?
 
 
Q