apple-data-persistence
Design or repair SwiftData, Core Data, file storage, migrations, save/cancel semantics, local-first data, CloudKit synchronization, and durable operation identity.
Files2
View on GitHubSKILL.mdskills/apple-data-persistence/SKILL.md
GitHubSave the changes someone meant to keep
A favorite can change on tap. A rename with Save and Cancel should take effect only at Save. Choose the write boundary before binding the controls.
Design choices
- Isolate cancellable edits. Hold new input in a value draft until Create. Apply edited fields to the record by ID. Rolling back a shared context can discard someone else’s pending work. <!-- EDIT-001 -->
- Make Save match its promise. Dismiss after the promised write succeeds. A Core Data child save may still need a parent save to reach disk. Retain failed input and distinguish local success from pending sync. <!-- EDIT-002 -->
- Retry the original change. Keep pending work tied to its record, account and operation. Reconcile a lost reply before resending. If the same field changed elsewhere, preserve the draft while resolving the conflict. <!-- EDIT-003 -->
Try it
Read the result from a fresh context or launch.
Cancel a rename while another window has starred the same record. Save the star and relaunch. The old name and new star survive. A failed rename stays editable for retry. <!-- EDIT-001 EDIT-002 -->
For sync, interrupt an acknowledgement after the write commits. Switch accounts before retry. Only the original account should receive the change, once. <!-- EDIT-003 -->