WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

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 Emerge

SPONSORED Optimize your app’s startup time, binary size, and overall performance using Emerge’s advanced app optimization and monitoring tools. Reliably measure app size, speed up your app's startup time with Emerge's Launch Booster, and much more. Emerge is actively used by many of the top mobile development teams in the world.

Find out more

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 Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

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.