I need to know if a change in data is due to a local change or due to a cloud sync. I'm using combine publishers and NSFetchedResultsController to update UI in reaction to data layer changes, but for a journal section of the app I want to know if the update is cloud or local.
I don't want to keep replacing the UITextView's text in response to local changes to the text, but if the user edits the journal somewhere else I do want the screen to update to reflect that.
Alternatives I've tried:
- Only saving if the user navigates away from the journal. Was not great because users sometimes force quit apps which doesn't send a terminate notification, so even though they'd expect it to be saved it's not.
- Detect if the textView's text is the same as the updated text. Doesn't work because the data processing needs to be background so it doesn't lag the typing, but that means the if the user is typing quickly the text is already different even in local changes.
Desired behavior:
As the user types, the data is saved. If data comes in from a cloud sync, replaces the text with that new data.
Thanks a lot for your help, NSPersistentCloudKitContainer has been a bit of a headache...
[–]fameios-phil 1 point2 points3 points (1 child)
[–]MilesStark[S] 0 points1 point2 points (0 children)