|
Good morning In a view I have several textfields for entering user information...which are set as empty string by default.
When the app is launched through an appleEvent I can set the initial value with: let kName = name ... struct BarcodeView: View { @State var name: String = kName The variable name is set in another class where the event is received....and the view is most probably not initialized.... But when the application is running and it receives another appleEvent the changes are not reflected... So how can a @State var be set from another class? thanks in advance richard |
|
Think you might want to look at Check out What’s the difference between @ObservedObject, @State, and @EnvironmentObject? |
|
@Nigel has the correct answer. I think of However, if you want to setup a solution to control ALL the switches in the entire house, you would NOT implement this solution using light switches in a single room. Instead, you'd probably opt for something more global. Something available in all the rooms of your house. What objects are available to ALL the rooms in your house? That's what |
|
Good morning This article explains it very well: https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-observedobject-to-manage-state-from-external-objects Though...I can't use @ObservedObject in the AppDelegate class where the event manager receives the URL parameters from the browser...
|
|
Hmm...also no success with this approach: https://stackoverflow.com/questions/62998695/how-to-confirm-observableobject-for-an-appdelegate The main problem is how to get data from AppDelegate into a specific view.... |
SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
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.