|
How can ı delete all item from core data ? Deleting one by one can be tiring sometimes. |
|
With a BatchDeleteRequest. Create one for each entity you have and isn't deleted automatically via delete rule "Cascade".
|
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until February 9th. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
|
|
I tried @Hatsuhira's method on the FriendFace app and it worked perfectly. Before I was using a for loop :P @Hatshuhira I have a question if you know please, I have a SQL data base browser and although the items are deleted every time, when I recreate them there is Z_PK column that keeps progressing the numbers, i.e.: Initially you enter 100 entries, each has Z_PK 1,2, up to 100 Once you delete, and re-enter the 100 entries, you still have 100 entries, but each entry now has Z_PK that starts from 101,102 etc |
|
@Bnerd This is because the PK (primary key) is an autoincrement. I know you can reset them with a SQL command. But I don't know how to do this with Core Data. I'm not even sure you can run a raw SQL command with Core Data. Usually, you shouldn't mess with the database primary keys although when every table is empty there shouldn't be a risk. The easiest way to reset it in your app is to delete it and reinstall it. |
|
Sorry. I don't understand. I am new in swiftUI. I created one function which name is deleteAll. But program said cannot find container in scope. I have one for each in list. I use onDelete to delete one by one. Where should i use this function ? Can you show one example for that ? |
|
I solved like this.
I assigned it to the button. When ı press the button all items delete. But ı cant see dynamically. Pages doesnt rendered. I can show only re open the app. |
|
I would have to see the rest of your code and what is the data source for your page? |
|
I figured out.
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until February 9th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.