我正在使用:
} else if segue.identifier == "logout" {
var currentUser = PFUser.currentUser()
PFUser.logOut()
}
点击退出按钮后,它再次转到登录界面,但是如果我点击登录按钮,它会将该用户重新登录,而无需再次输入任何凭据。
为什么在退出时没有将用户重置为nil?
@IBAction func logIn(sender: AnyObject) {
if username.text == "" || password.text == "" {
displayNewAlert("Field(s) Empty", message: "Please Enter a Username and Password")
} else {
activityIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50))
activityIndicator.center = self.view.center
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(activityIndicator)
activityIndicator.startAnimating()
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
let user = PFUser()
user.username = username.text
user.password = password.text
var errorMessage = "Please Try Again Later"
PFUser.logInWithUsernameInBackground(username.text!, password: password.text!, block: { (user, error) -> Void in
self.activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
if user != nil {
self.performSegueWithIdentifier("login", sender: self)
} else {
if let errorString = error!.userInfo["error"] as? String {
errorMessage = errorString
}
self.displayNewAlert("Failed Log In", message: "Please enter a valid username and password")
}
})
}
}
答案 0 :(得分:0)
我想出了这个问题,其他人都在想。我在注销和登录之间做了一个故事板。
我应该一直在使用:
newlist = [file1, file2, etc...]
这是执行注销的正确方法。不是来自上面提到的
@IBAction func logOut(sender: AnyObject) {
PFUser.logOut()
let currentUser = PFUser.currentUser()
self.dismissViewControllerAnimated(true, completion: nil)
}