This is probably super simple and I am just missing something. I am trying to check if the view is loaded and visisble. Two edge cases, if it is visible, I just update a string inside the class, if it is not visable, I present the class. I tried to use .isViewLoaded on the class from another class and always got false returned. So I tried just have an initial value on the class that just gets updated is viewDidAppear gets called, but when accessing that value from another class I get no luck. Could anyone help here
class TimeController: UIViewController {
var openingTimeValue: String = ""
var timeShown: Bool = false
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
return self.timeShown = true
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidAppear(animated)
return self.timeShown = false
}
This is the class where I am setting the values and am trying to update when view is shown^
if self.timeController.timeShown == true {
self.timeController.openingTimeValue = timeUntilOpen
return
} else {
DispatchQueue.main.async {
_ = self.presentWeAreClosed(opensIn: timeUntilOpen)
}
This is the class I always get false from. I originally tried to do this.
if self.timeController.isViewLoaded
But still got false. I know it is something to do with inheritance which is what I'm still trying to get my head around in Swift. Thanks :)