|
I'm having real trouble with the second challenge in the Flashzilla project. I'm trying to work out how to tell from the |
|
I have a same problem here and I've been stuck on this for a while now :( : https://www.hackingwithswift.com/forums/100-days-of-swiftui/day-91-flashzilla-challenge-2-3/7793 Hope you'll get some response cause I'd like to move forward and it's really frustrating :( |
|
I did eventually work this out! I went back to the Unwrap app and revised my closures, and came up with the below. In
and then in
|
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
|
|
OMG, I've just spent so long trying to figure this out. I've then tried to implement your code but couldn't get that to work either. Then I noticed the comment about about the bug and the dispatch queue code. Turns out my first attempt yesterday was working except for the bug... I've just added the dispatch queue code around my card insertion and boom, all working fine. So frustrating, but also kind of a relief that I was so close to resolving this except for the bug. Incidentally, do you have a link to a discussion around the bug? edit: Don't worry, I've found it: https://www.hackingwithswift.com/forums/100-days-of-swiftui/day-91-flashzilla-challenges-can-t-seem-to-readd-a-card-successfully/2037/6401 |
|
Hello everyone! I'm also stucked on this challenge too. But I found better solution with less code and without DispatchQueue.main. So Paul said that we should rethink our Card model and add an UUID(). When you create your List() it's identify your objects by UUID of the Card. And it's cause our problems. SwifUI manage object with the same UUID trying to remove from Array and append to it back almost at the same time . So when you are trying to move Card to the end just set a new UUID() to the card. And everything will works fine without using delay on DispathchQueue. |
|
I'm also and still having trouble, even after integrating Paul's solution. He hasn't shown this specific case in the video, so I don't know whether it would work for him or not. First of all, I'm not uising remove and insert, but
and my list is using However it still causes problems in certain circumstances. If I swipe everything to left only, it seems to work. As soon as I swipe one element to the right and I reach the former end of the list, the next item is not clickable. Easy to reproduce: Just swipe everything to right, then the last element to left. It reappears, but is not draggable. Weird combinations also exist with some left, some right and from some elment on, it's not draggable anymore. Anyone else facing this issue? |
|
|
|
|
|
Hi everyone, so I found a really simple solution to this problem we all have. I see there are solutions with DispatchQueue and that's great but there is delay that you need to have for it to work. I have found a better solution for that problem and you do not need to use DispatchQueue. It is pretty much simple. Here are the steps:
Keep it going! |
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.