UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: SwiftData and iCloud showing ADDED records between devices correctly, but not showing EDITED records automatically

Forums > SwiftUI

With SwiftData and iCloud, should edited records be automatically shown/refreshed on each devices screen, just like added and deleted records?

I have a small app using SwiftData that allows create, add, update, and delete of items, with a list showing all the items.

I have enabled iCloud and have confirmed that when I ADD a new record on device-1 that it auto-magically appears on device-2 without touching anything. The new entry shows up at the bottom of the list on device-2 within a couple of seconds. I was surprised at just how easy Apple have made it to handle that.

However, when I EDIT an existing item on device-1, the amendment is not automatically refreshing on device-2. If I shut down the app on device-2 and start it again, then the edited records are correctly shown. Same thing vice-versa. Edits on device-2 are not shown on device-1 either, until I shut down the app and start it again.

Deleted records are synchronised and automatically refreshed on the screens correctly between the devices. It is only edits that are not automatically being shown.

I have also tried using the developer console. If I add or delete a record on the console, they are automatically shown on both devices, however if I edit a record on the console, neither device-1 or device-2 show the edited record until I close down the app and start it again on each device.

Is there something obvious that I have overlooked here?

Should edited records be automatically shown on each device, just like added and deleted records?

   

I solved it. Not entirely sure how, but it now definitely does synchronise add, delete, and edit.

   

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.