NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>

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?

2      

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.

1      

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.

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

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?

1      

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. 🤷

1      

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

1      

Well done @TwoFortyTwoApps

Here

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

1      

if you want to find this types of stuff visit my link: what to do

1      

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

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

1      

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

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.