0

Currently I am trying to redirect user to dashboard after checking if they have valid credentials. This is my code below. I've tried creating variables (bools) to check for this condition, however, variables don't save updated value in completion handler

@IBAction func loginPressed(_ sender: UIButton){ //login works
  
    guard let email = enterEmailTextField.text else {return}
    guard let password = enterPasswordTextField.text else {return}
    let loginModel = LoginModel(username: email, password: password)
    APIManager.shareInstance.loginUserAPI(login: loginModel) { (result) in
        switch result{
        case .success(let json):
            print(json as AnyObject)
        case .failure(let err):
            print(err.localizedDescription)
        }
    }
}

So my question is, how do I "extract" some type of information when the user logs in (confirming valid credentials) and then redirect to another view?

Thank you in advance!

jnpdx
  • 45,847
  • 6
  • 64
  • 94
ACDA100
  • 43
  • 4
  • In terms of "extracting" some information, it looks like you already have some `json`, which presumably you would want to use, but we don't have any information about what that object looks like. You can certain save properties you need to your view controller if you make properties to represent them. Then, to go to a new view, we don't know whether you're using Storyboard or programatic transitions. Maybe take a look at this: https://stackoverflow.com/questions/27604192/how-to-segue-programmatically-in-ios-using-swift – jnpdx Feb 12 '22 at 05:04
  • What logic are you using to presenting/managing views? – Abhinav Mathur Feb 12 '22 at 07:41

0 Answers0