Learn Courses My Dashboard

Deleting collection view cell - core data

Hi guys, hope you are all safe. I’m working on an app that lets user add and store images. I looked around an managed to use collection view and populate it with core data, and have images open in detail view screen (I see not much info on UICollectionview online!). I’m stuck at deleting cell with image. I did take a couple of courses and saw you tube videos but they don’t work for core data delete function. (I can always use tableview as fallback, but thought since it’s images I’m working with it’d be nice to give the photo library feel.)
When I try those methods I get this: “The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (0), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus …”

Pls let me know if there’s any way to address this. Thanks a lot!

it seems like you didn’t update your dataarray (for the collectionview) after deleting. so its confused why theres still data in it…
check how you are using and accessing your context and see if it lines up

1 Like

Hi Francis, thanks for the reply, I did do reloadData), let me look again and see. Is there a lesson here on this topic? I know Chris uses colectionview in the card game app but it doesn’t have cell deletion if I remember right. Thanks again.

you can check the updated database course for SwiftUI there should be a section for CoreData there

1 Like

Thanks will do. I’m not using UI yet, using Storyboard, hope it’s not too different.

1 Like