|
Just a quick question about diffable datasources (collectionview). There's no need to have an array of your type anymore, right? Or wrong? Why I am asking; I got this collectionview of Projects. When I preload some dummy projects, I see them and I can edit them. When I add a new Project (snapshot 1 new Project), after adding/editing I see only the newly added/edited project, the rest is gone. If I start empty and add a new Project, I see the new Project in the collectionview. If I add another Project, I just see this lastly added Project. What Am I missing here, I think I am missing something fundamental ... |
|
This is a pretty good tutorial on how to use diffable data source. I believe if you're trying to append a new project to your data source while animating the difference, you'll still need to maintain an array of previous projects. https://wwdcbysundell.com/2019/diffable-data-sources-first-look/ |
|
Yes, thank you. It finally occured to me that the snapshot you provide is all the collectionview will show. So I have to maintain state by first capturing the current state of the datasource and then apply the new snapshot, including existing and new projects ... I think I can get a bit further now .... |
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Ok, I've got a preliminary working version now for adding and updating Projects. But I wonder if all the array stuff I do is the way to go. I feel I should do more with the snapshot. Should all logic from the save method be in the update method?
There is very little on the web as of current on adding and deleting with diffable datasources. Any help appreciated! |
|
@Gakkienl I would leave update method as it is to be honest. Just a small remark, you do not need to call |
|
|
|
@Gakkienl There must be an issue somewhere else. I am pretty sure it's not needed. Are you sure it uses your collection's dataSource is set to your Let me know if you got any more questions :) |
|
I'm 100% sure the datasource is used. But after updating an item I do need to do a reload of the tableview, or it will still show the unchanged data ... Thanks for the gist! Looking at it now! EDIT Perhaps when I've implemented a few more things you could perhaps review my code some time .... |
|
Sure, feel free to poke me here on forum or DM me on Twitter and I can take a look. |
|
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!
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.