How To Match Password In RootViewController Swift

I am doing a task in which the password is set in the application Then the Password ViewController Set In the Root , when I set up the password and after Some Time open the app, the password View controller is open if password does not set then open login page.

My work was almost completed but at the end of the work, I was confused about matching passwords How To match Password Because i am Using Same View Controller To Enter Password And Match Password.

This is my code for Set password:

let AllText = TF1.text! + TF2.text! + TF3.text! + TF4.text!
DBManager.sharedDatabase().insertRecord("INSERT INTO AppPassword (UserId,AppPassword) VALUES ('\(userId)','\(AllText)')")
UserDefaults.standard.set(true, forKey: "isValidLogin")  
AlertWithTimer(Alert: "Success", string: "Done \n You have Set password ")

This is code for set ViewController in Root in app delegate:

 func  setRootVC() {
    let storyboard =  UIStoryboard(name: "Main", bundle: nil)
    if  UserDefaults.standard.bool(forKey: "isValidLogin") {
        let tabbarcontoller  = storyboard.instantiateViewController(withIdentifier: "SetPassword")
        self.window?.rootViewController = tabbarcontoller
    } else {
        let navVC =  storyboard.instantiateViewController(withIdentifier: "navVC") as! UINavigationController
        let login = storyboard.instantiateViewController(withIdentifier: "LoginUser")
        navVC.setViewControllers([login], animated: false)
        self.window?.rootViewController = navVC