samedi 30 juillet 2016

keep user logged in ios app swift

I make a login and signup app when I run my app and login evrything is going ok but when I stop my app and run it again login page showing again can I make user loged in

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(true)

    let prefs:NSUserDefaults = NSUserDefaults.standardUserDefaults()
    let isLoggedIn:Int = prefs.integerForKey("ISLOGGEDIN") as Int
    if (isLoggedIn != 1) {
        self.performSegueWithIdentifier("goto_login", sender: self)
    } else {
        self.usernameLabel.text = prefs.valueForKey("USERNAME") as? String

    }
}

Aucun commentaire:

Enregistrer un commentaire