错误域=解析代码= 209"操作无法完成

时间:2015-03-26 08:07:54

标签: ios iphone swift parse-platform

我安装了ParseStarterProject swift版本并使用以下代码创建了一个新用户:

var user = PFUser()
...
user.signUpInBackgroundWithBlock...

然后我再次运行该项目,我收到以下错误:

2015-03-26 09:49:25.485 ParseStarterProject [14768:199520] [错误]:会话令牌无效(代码:209,版本:1.7.0) 2015-03-26 09:49:25.489 ParseStarterProject [14768:199521] [错误]:最终错误地运行命令失败:错误域=解析代码= 209"操作无法完成。 (解析错误209。)" UserInfo = 0x7fcda3cb6680 {error =无效的会话令牌,代码= 209}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我认为让当前用户也执行登录但不会。 所以问题是我试图在不执行登录的情况下保存对象。

func login() {
    var username = username from UI or key store
    var password = password from UI or key store
    if let currentUser = PFUser.currentUser() {
        println("current user is \(currentUser.username)")
        username = currentUser.username
    }
    PFUser.logInWithUsernameInBackground(username, password:password) {
        (user: PFUser!, error: NSError!) -> Void in
        if user != nil {
            println("successful login with \(user.username)")
            self.saveSomething()
        } else {
            println("failed login with \(user.username)")
        }
    }

}

func saveSomething() {
    var gameScore = PFObject(className:"GameScore")
    gameScore["score"] = 1337
    gameScore["playerName"] = "Sean Plott"
    gameScore["cheatMode"] = false
    gameScore.saveInBackgroundWithBlock {
        (success: Bool, error: NSError!) -> Void in
        if (success) {
            println("The object has been saved")
        } else {
            println("There was a problem, check error.description")
        }

    }
}