Skip to content

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

@evandelaney

Description

@evandelaney

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions