I'm trying to prevent a function from being called concurrently at the same time. To test this out, I have purposely called both functions in viewdidload and viewwillappear. When i load the application it only gets called once. But when I switch views and return back to the controller, "viewwillappear" doesn't call the function? Why is this happening. I need viewwillappear to call the function.
lazy var executeOnce: () -> Void = {
print("hrlllo ")
doSomething()
return {}
}()
override func viewDidLoad() {
super.viewDidLoad()
executeOnce()
}
override func viewWillAppear(_ animated: Bool) {
executeOnce()
}