I am updating my App to support sharing of Cloudkit data with other iCloud users. Is there a way to specify the NSPersistentStore and the CKRecordZone.ID for my fetch? I do not see an option in the predicate.
struct MyView: View {
@FetchRequest<CD_MyManagedObject> private var fetchRequest: FetchedResults< CD_MyManagedObject >
init() {
_fetchRequest = FetchRequest(entity: CD_MyManagedObject.entity()
, sortDescriptors: []
, predicate: myfetchPredicate())
}
}
You can't specify the zone because that is set automatically but you can choose the store with:
https://developer.apple.com/documentation/coredata/nsfetchrequest/1506518-affectedstores
You need to retain the
NSFetchRequestobject somewhere so you can reuse it in theFetchRequeststruct init every time theViewstruct is init otherwise it's a memory leak.