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

SOLVED: Ultimate Portfolio App - deleteAll doesn't delete?

Forums > Articles

After calling deleteAll() and creating a new dataset, old data is still visible in the ProjectsView. At least for me! Is this expected, is the View holding on to some cached data?

6      

Same question here. Hitting "add" several time should to my understanding delete all projects/ items and create 5 new projects. However old data keeps staying.

5      

Well I really don't know what went wrong here, but editing the Add Data button in HomeView and rebuilding made it work as expected. Weird.

5      

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.

Learn more here

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

Could you kindly let me know what you edited exactly on the Button?

5      

I tested to add a new button doing only the delete, and it worked fine. Then I undid my edit, back to the original, and it still worked. I really can't figure out what happened. 🤷

5      

Looks like we need a call to dataController.save() in HomeView after the call to dataController.deleteAll(). Look at this tweet.

https://twitter.com/MrGLWatson/status/1320448229914353666

5      

Well done @TwoFortyTwoApps

Here

Button("Add Data") {
    dataController.deleteAll()
    dataController.save()
    try? dataController.createSampleData()
}

5      

This is still not updating until I restart the app even after doing

Button("Add Data") {
    dataController.deleteAll()
    dataController.save()
    try? dataController.createSampleData()
}

5      

5      

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.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.