How to go to viewcontroller after certain actions, like here:
func requestForAccessToken(authorizationCode: String) {
Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: nil)
.responseJSON { response in
switch response.result {
case .success(let JSON):
let response = JSON as! NSDictionary
let accessToken = response.object(forKey: "access_token")!
UserDefaults.standard.set(accessToken, forKey: "LIAccessToken")
UserDefaults.standard.synchronize()
///here...
DispatchQueue.main.async(execute: { () -> Void in
// self.dismiss(animated: true, completion: nil)
let secondViewController: LoginViewController = LoginViewController()
self.present(secondViewController, animated: true, completion: nil)
})
case .failure(let error):
print("Request failed with error: \(error)")
}
}
}
I create vc in storyboard and make vc class file. Maybe I must make something other.
let secondViewController = UIStoryboard(name:"LoginViewController", bundle: Bundle.main).instantiateViewControllerWithIdentifier("LoginViewController") as? LoginViewControllerself.present(secondViewController, animated: true, completion: nil)