Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

core data - How to write a CloudKit NSPredicate for a many-to-many relationship, on CloutKit database created using NSPersistentCloudKitContainer

I want to write an NSPredicate for a CloudKit query on a database created using NSPersistentCloudKitContainer.

Normally this is quite easy, but in my case I want this predicate to filter the entities according to a many-to-many property. This seems to be much harder than filtering by other CloudKit properties, as it seems that NSPersistentCloudKitContainer creates a dedicated "CDMR" table to handle many-to-many relationships [link to doc specifying this].

So if I am understanding correctly, I have to first query this CDMR table, get the entity IDs of the entities which satisfy said many-to-many relationship, and then fetch the entities themselves. It seems it would take 2 fetch requests, or more I am not sure yet. Is there a less cumbersome way to do this? Ideally on a single fetch request to CloudKit?

question from:https://stackoverflow.com/questions/65874714/how-to-write-a-cloudkit-nspredicate-for-a-many-to-many-relationship-on-cloutkit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...