|
Hi, just ended day 72 and everything is working but I keep getting this purple error. Everytime i move the map it starts to create more and more errors. Since this was a follow tutorial, went on Github to check Paul's code and it is exactly like mine, so I don't know what it can be wrong. Searched for similar problems and noticed another user complaining about the same. Is it a bug related to newer version of XCode? |
|
@orocha is seeing purple!
Think about what the compiler is telling you!
While you are telling SwiftUI to change a view based on some parameters you have provided, you then change those parameters as SwiftUI is updating the view! Which value should it use? The one you gave it when you started the update? Or the one you calculated on the fly whilst it was updating? You see, as soon as your change a value in a view struct, the struct becomes invalid and must redraw itself. So consider the situation where the view has grabbed your new parameter and starts redrawing the view. It's doing great and gets 92% of the way through redrawing and updating the view. BUT THEN, you change a parameter! It was ever-so-close to finishing drawing the updated view, but you changed a parameter value, thus invalidating the yet-undisplayed view! So SwiftUI starts redrawing (again!) with an even newer value. Thinking of another example, it may be similar to changing a tyre on your Citroen whilst you are driving down the autopista! Provide some code snips so we can see the view that's being updated, if you please. Please note! WWDC introduced new Swiftier version of MapKit. Comments here to fix your Day 72 code may be out-of-date based on latest updates! See -> What's new in MapKit 2023 Please share!These improvements may eliminate the problems associated with wrapping a UIKit interface into SwiftUI. It would be great for you to return here and provide your updates including your impressions of the new MapKit updates! |
|
Thanks for the help @Obelix and @stonesexy3. Reviewed my code again and checked with Paul's code to see if there was any difference that I might have overlooked. Didn't find anything. Regarding the version part, Paul's code was made in iOS 15 and mine's using iOS 16.2. Since what was causing the error was me moving the map, checked my Map code to see if i was changing anything in ContentView instead of in my View Controller but only the "selectedPlace" is changing something in ContentView as far as i can tell... Here's my View Controller code:
And my ContentView code:
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
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.