In this video we will focus on creating the view model that will power the character details screen. This green will help us show more details after a user selects a single characters cell. We will be working in Xcode 14 and Swift 5.
💻 Source Code:
🎥 Subscribe for more:
😎 Like my teaching style? Check out some of my most popular courses!
👉🏼 Connect (personal LinkedIn)
🚀 Follow on LinkedIn
** Popular Series
Building Instagram:
Building TikTok:
SwiftUI for Beginners:
** Get Skillshare free for 2 Months and learn iOS
** Manage all your investments from app earnings on Betterment!
** Grow your own Youtube tech channel with TubeBuddy:
#swift
Watch more new videos about iOS Academy | Synthesized by Mindovermetal English
Hey Afraz, thank you very much for making this series, it's been a joy to follow your thought process throughout the videos. Keep it up, man!
I was playing around with the app and managed to reproduce a crash while fetching more data (I think it's the same crash you came across in previous videos). It's pretty easy to reproduce: you just need to frantically scroll down, as that should trigger several new fetch requests for the same page.
After a bit of digging, it seems to me like the cause of the problem is the Timer you fire off when the user scrolls past the content, as we construct our request URL 0.2 seconds prior to the execution of the service. In the right conditions, this would create a duplicate request, since we would be using an old URL (assuming new data came in during this interval). This request would then fetch data we already have, updating only the `characters` array, but not `cellViewModels` (we check for duplicates on this one). Since `cellViewModels` provides the count of items for a given section, and it doesn't have the viewModels for the duplicate data, we've got ourselves a crash!
I didn't quite understand the reasoning behind this Timer in the first place, so it would be awesome if you could go over this one more time as well as go through this problem and how you would solve it.
Thanks once again for making this series! I can't wait for the next episodes 🙂