gpt4 book ai didi

parse-platform - 使用 Swift 1.2 注册解析用户

转载 作者:可可西里 更新时间:2023-10-31 23:58:08 24 4
gpt4 key购买 nike

我按照描述使用 Parse.com 的注册功能 here .这是我的代码:

 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.
}
}
}

不幸的是,我已经将我的项目从 swift 1.1 更新到 swift 1.2 并得到以下编译器错误:

Function signature '(Bool!, NSError!)->void is not compatible with excepted type '@objc_block (Bool,NSError!)->Void'

它在下面一行:

user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in

有谁知道我该如何解决这个问题?谢谢!

最佳答案

您的成功变量是一个“Bool!”但该 block 返回的是“Bool”(没有感叹号)。

解决方案是:

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.
}
}
}

查看更多关于选项的信息 go to the apple doc

关于parse-platform - 使用 Swift 1.2 注册解析用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29533811/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com