TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Day 71: SwiftUI only version SO CLOSE... and yet so far. (Was an Xcode/Simulator issue, reinstall fixed it)

Forums > 100 Days of SwiftUI

**** A wipe and reinstall of Xcode made the broken code work.

When I tried to build this project using the UIViewRepresentable, for some reason I couldn't get it working.

When I switched over to the new SwiftUI Map() it worked just fine to add pin, but it means I've had to write some new code for adding annotations.

I am so so close to getting it to update, but as soon as I edit the text field - BONK, it all dies.

I have tried a few different styles of bindings and they all die when the TextFields on the EditLocationView get activated.

I feel like I'm trying to do something really common, pass a textfield change back up to an observed array of structs in a class wrapper. What am I doing wrong?

Xcode 12.5, not an M1 mac

Ostensibly it's this step: https://www.hackingwithswift.com/books/ios-swiftui/extending-existing-types-to-support-observableobject

Here is my current code:

Related Content:

2      

Not sure if this will help, but I do know that navigationBarTitle is now deprecated for iOS 13.0 - 15.0, and you should use navigationTitle instead - Apple Developer Documentation

Similarly replace navigationBarItems with .toolBar and ToolbarItem - link

3      

Thanks @Greenamberred!

Fascinatingly enough... it works now! Hunh! Would not have thought that was the problem in a million years. Thanks!

Edited:

Actually, retested it, and it isn't those changes that fixed it, but since moving my "source of truth" to the JSON file, that did.

So this is a semi-solved? In that it works now, but I'm not 100% sure why it wasn't working before... hmmm....

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

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.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.