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:
-------------------------------------