【发布时间】:2015-08-14 04:45:02
【问题描述】:
我正在尝试将 integer 值保存到 Parse.com,但出现错误。我将 Parse 类中的对象设置为 Number。
这是我的代码:
if let currentUser = PFUser.currentUser() {
currentUser.fetchIfNeededInBackgroundWithBlock({ (foundUser: PFObject?, error: NSError?) -> Void in
// Get and update score
if foundUser != nil {
let score = foundUser!["score"] as! Int
let points = 100 + score
foundUser!["score"] = points
foundUser?.saveInBackgroundWithBlock({ (succeeded: Bool, error: NSError?) -> Void in
if succeeded {
println("score added to user")
}
})
}
})
}
有人可以帮忙吗?
谢谢
【问题讨论】:
-
你的错误是什么,你在哪一行得到它?
-
让 score = foundUser!["score"] as!诠释
-
我得到这个错误:致命错误:在展开可选值时意外发现 nil
-
打印您的 score 变量并检查是否可以将其转换为 int。
-
分数打印描述:6171707936 分数打印描述:6176593344
标签: swift parse-platform integer