I have a service class, AuthManager, that has a method in it as below:
public func logoutAuth(from viewController: UIViewController, completion:((_ result: Bool) -> Void)? = nil) {
let logoutString = "\(self.oAuthBaseServerURL)/logout.jsp"
// Present the Sign Off ViewController
if let logoutURL = URL(string: logoutString) {
let logoutController = SFSafariViewController(url: logoutURL)
let logoutDelegate = SFSafariViewDelegate(completion: completion)
logoutController.delegate = logoutDelegate
viewController.present(logoutController, animated: true, completion: nil)
}
}
I call this service from an instance of it (singleton in a global state) in my view controller like this:
GlobalState.AUTHMANAGER().logoutAuth(from: self, completion: self.completeLogout)
However, I am getting this error:
[Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<SFSafariViewController: 0x7ff9b1060800>)
I'm not sure why that is deallocating too early. I've tried making the SFSafariViewController an instance variable and assigning it in the method instead, which yields the same error.