Welcome to OGeek Q&A 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...