You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: Confused with one place in SyncCoordinator #34
fileprivatefunc fetchLocallyTrackedObjects(){self.perform{
// TODO: Could optimize this to only execute a single fetch request per entity.
varobjects:Set<NSManagedObject>=[]forcpinself.changeProcessors {guardlet entityAndPredicate = cp.entityAndPredicateForLocallyTrackedObjects(in:self)else{continue}letrequest= entityAndPredicate.fetchRequest
request.returnsObjectsAsFaults =falseletresult=try!self.syncContext.fetch(request)
objects.formUnion(result)}self.processChangedLocalObjects(Array(objects))}}
In SyncCoordinator, since each ChangeProcessor only care about their own tracked objects fetched from cp.entityAndPredicateForLocallyTrackedObjects(in:)
Why here union them together and send to every ChangeProcessor
I've changed it to the code below and it works well.
So what's the purpose or advantage of the above one?
fileprivatefunc fetchLocallyTrackedObjects(){self.perform{
// TODO: Could optimize this to only execute a single fetch request per entity.
forcpinself.changeProcessors {guardlet entityAndPredicate = cp.entityAndPredicateForLocallyTrackedObjects(in:self)else{continue}letrequest= entityAndPredicate.fetchRequest
request.returnsObjectsAsFaults =falseletresult=try!self.syncContext.fetch(request)self.processChangedLocalObjects(result, using: cp)}}}
Activity