1

我正在使用来自 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'

有小费吗?

4

2 回答 2

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) }
于 2015-04-27T11:15:19.873 回答
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!)
        }
    }
于 2015-04-27T12:45:34.283 回答