【发布时间】:2015-04-25 00:58:36
【问题描述】:
我是 swift 新手,我很难弄清楚为什么 https://www.parse.com/docs/ios_guide#users/iOS 上的代码对我不起作用
var user = PFUser()
user.username = "myUsername"
user.password = "myPassword"
user.email = "email@example.com"
// other fields can be set just like with PFObject
user["phone"] = "415-392-0202"
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
} else {
let errorString = error.userInfo["error"] as NSString
// Show the errorString somewhere and let the user try again.
}
}
这一行
user.signUpInBackgroundWithBlock
给我以下错误
Cannot invoke 'signUpInBackgroundWithBlock' with an argument list of type '((Bool!, NSError!) -> Void)'
我可以将 Objective-C 的代码复制并粘贴到我的项目中,它运行良好,但是当我尝试对 Swift 代码执行相同操作时。我收到此错误消息。我还需要做些什么才能让它在 Swift 中正常工作吗?
【问题讨论】:
-
你使用的是 swift 1.1 还是 1.2?如果您使用的是 Xcode 6.3+,那么您使用的是 1.2。 Parse 文档反映了 1.1。
标签: ios iphone swift parse-platform pfuser