【问题标题】:SWIFT + Parse signUpInBackgroundWithBlock no longer works: Xcode 6.3.1 [duplicate]SWIFT + Parse signUpInBackgroundWithBlock 不再有效:Xcode 6.3.1 [重复]
【发布时间】:2015-07-05 17:46:06
【问题描述】:

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

有什么建议吗?

【问题讨论】:

    标签: xcode swift parse-platform xcode6.3.1


    【解决方案1】:

    你试过没有“?”在布尔之后

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

    【讨论】:

      【解决方案2】:

      试试这个。

      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!)
              }
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多