Click here to Skip to main content
15,850,445 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi my friends. this is my code for login page that work correctly:

func doLogin(username: String, password: String) {
        let parameters = [
            "NationalCode": username,
            "password": password
        let url = "http://home/login"
        Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.httpBody).responseJSON { response in
            if let data = {
                let json = String(data: data, encoding: String.Encoding.nonLossyASCII)
                if json=="0"{
                    let alert = UIAlertController(title: "error", message: "wronge username or password", preferredStyle: UIAlertControllerStyle.alert)
                    alert.addAction(UIAlertAction(title: "try", style: UIAlertActionStyle.cancel, handler: nil))
                    self.present(alert, animated: true, completion: nil)
                    DispatchQueue.main.async(execute: { () -> Void in
                        self.performSegue(withIdentifier: "loginToMain", sender: self)
                    let jsonData = try? JSONSerialization.jsonObject(with: data, options: [])
                    guard let dictionary = jsonData as? [String:String] else { return }

when i click login button, i go to next page.
now how can i say the app do not show login page for next running until i log out??

(sorry i,m new in swift)

What I have tried:

Updated 14-Oct-20 3:49am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900