我正在使用parse.com上针对user.signupInBackgroundWithBlock
user.signUpInBackgroundWithBlock {
(succeeded: Bool?, error: NSError?) -> Void in
if let error = error {
let errorString = error.userInfo?["error"] as? NSString
self.showAlertWithText(message: "\(error)")
} else {
self.performSegueWithIdentifier("createNewUserAndGoToDashboard", sender: self)
}
我刚刚升级到x-code 6.3.1,它不再有效。这是直接从Parse.com复制的,但我在user.signUp行上收到错误:
1.0 / SIgnUpViewController.swift:48:46:函数签名'(Bool?, NSError?) -> Void'
与预期类型不兼容
'@objc_block (Bool, NSError!) -> Void'
任何提示?
答案 0 :(得分:3)
你试过没有“?”在布尔之后
user.signUpInBackgroundWithBlock {
(succeeded: Bool, error: NSError?) -> Void in
if let error = error {
let errorString = error.userInfo?["error"] as? NSString
self.showAlertWithText(message: "\(error)")
} else {
self.performSegueWithIdentifier("createNewUserAndGoToDashboard", sender: self) }
答案 1 :(得分:0)
试试这个。
user.signUpInBackgroundWithBlock { (returnedResult, returnedError) -> Void in
if returnedError == nil
{
self.dismissViewControllerAnimated(true, completion: nil)
}
else
{
self.showAlert("There was an error with your sign up", error: returnedError!)
}
}