Click here to Skip to main content
14,693,599 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 = response.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)
                    return
                }
                else{
                    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 }
                    print(dictionary["name"])
                }
            }
        }

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:

-------------------------------------
Posted
Updated 14-Oct-20 3:49am
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



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