I am learning SwiftUI and am really struggling so any pointers to get me in the right direction would be really appreciated.
Im trying to get the following type of behaviour.
1.When the app loads, I want to set a variable (dateTimeSnapshot) of the current Date/time the user logged in.
2.I want dateTimeSnapshot to be accessible from each UIView.
3.I want some UIViews to be able to update it to another date/time and once updated any view that needs the variable to now see the updated (not original) value.
I originally passed the dateTimeSnapshot variable via segues and that did work but I then thought to look for easier alternatives.
I then looked at @ObservableObject and @Publish which initially works but I can't find a way to update the value outside the ObservableObject class.
I then looked at a Class or a Struct but each UI that I create the instance, it seems to create a new one, rather than referencing the original one... again I dont know how to update the value from another UI View.
Sorry, I know this is a basic question, but Im going round in circles trying to work out what is the correct way to do it.
Any pointers or examples would be really appreciated.