Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is notifyAboutChangedObjects called when sync context did save? #50

Open
evandelaney opened this issue Jun 10, 2018 · 1 comment
Open

Comments

@evandelaney
Copy link

When we receive a did-save notification, we call notifyAboutChangedObjects(from notification:), which, in turn, calls processChangedLocalObjects(_:). That method will then distribute the objects to all change processors

Calling notify... happens on did-save notifications for both MOCs (view and sync).

I see why this is done for the view context; after merging the changed MOs into the sync context, we want to send them along to the change processors where presumably they will be uploaded to CloudKit by MoodUploader.

But, I do not understand why notify... is called when the sync MOC did-save. The remap calls should be mostly a no-op; there's an early return:

guard unmappedMO.managedObjectContext !== context else { return unmappedMO }

I believe the change processors are also a no-op since there's nothing more do download or upload. Am I correct about the no-op on the change processors? Is this by design? Why?

Aside: Could there be situations where saves are called back-to-back and an upload change processor didn't finalize the Mood upload by setting its remoteIdentifier property?

@davidfrog
Copy link

#26 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants