I need to check which CKRecords in CloudKit container don't have parent record yet. How I can fetch only records that do not have parent yet? I've tried NSPredicate, but getting an error "Unknown field 'parent'".
Asked
Active
Viewed 134 times
0
-
What do you mean by "parent". Records only have relations to other records if you set them up yourself (with reference fields). If you want to find records without a reference field, that can be done with a predicate. – john elemans Jul 21 '20 at 17:08
-
Hi John. If we are talking about the same. CKRecord has 'parent' property (it can be set using setParent(:) method), in Dashboard I see that as 'reference'. Tell me please how to find records without a reference field using predicate as you said. – bodich Jul 22 '20 at 10:41
-
I'm still working on this, but for now I can tell you that the setParent will create a field in your record and set a reference to the parent. The field is called "parent", but because the field called "parent" does not appear in your schema, you cannot search on it. – john elemans Jul 22 '20 at 18:57
-
setParent does not create database field, it's just set a CKRecord object property. I know that I cannot search by it, that's the reason of my question actually. I wrote about "Unknown field 'parent'" in question from the beginning. – bodich Jul 23 '20 at 07:39
1 Answers
0
You can’t achieve this with a simple query, but you can filter fetched records where Share property is nil.

Stamenkovski
- 959
- 1
- 6
- 10
-
The problem is I am using FetchedResultsController, and it will fire and fetch whole database and filter it for nothing in 99% cases. I've solved this problem already, created hasRemoteParent property for Entity and set it to true only after successful CloudKit setting parent operation. – bodich Jul 27 '20 at 08:07