Xcode 6.3更新导致工作应用程序失败 - 现在工作的不会

use*_*770 9 xcode ios swift

我不知道是否有其他人经历过这个,但我有一个我正在建设的应用程序,它工作得很好.然后我愚蠢地允许mac安装和xcode更新.接下来我知道,我打开项目并且构建失败并出现21个错误.我修了20个.顺便说一句,其他任何人发现此PF_Nullability错误的问题,请检查出来.

这适用于20个错误,但最后一个是在一个正常工作的函数中.在这个函数中,我在parse.com上查询一个数据类,并获得一个随机对象来填充我视图中的变量controller/app/whatevers.我把这个函数放在下面所以你可以看到整个事情,但这是错误的行:

 countQuery.countObjectsInBackgroundWithBlock { (count: Int32, error: NSError!) -> Void in
There error: cannot invoke 'countobjectsinbackgroundwithblock' with an argument list of type '((Int32, NSError!) - Void in)'
Run Code Online (Sandbox Code Playgroud)

这是整个函数,这里希望它只是一个类似于其他20个修复的语法:

     func CallData() {
    var countQuery = PFQuery(className: "QandA")
    countQuery.countObjectsInBackgroundWithBlock { (count: Int32, error: NSError!) -> Void in
        if (error == nil) {
            let randomNumber = Int(arc4random_uniform(UInt32(count)))
            var query = PFQuery(className: "QandA")
            query.skip = randomNumber
            query.limit = 1
            query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]!, error: NSError!) -> Void in
                if (error == nil) {
                    var object: AnyObject = objects[0]
                    self.Question = object  ["Question"] as String!
                    self.Answers = object  ["Answers"] as Array!
                    self.Answer = object  ["Answer"] as String!

                    if (self.Answers.count > 0) {
                        self.QuestionLabel.text = self.Question
                        self.Button1.setTitle(self.Answers[0], forState: UIControlState.Normal)
                        self.Button2.setTitle(self.Answers[1], forState: UIControlState.Normal)
                        self.Button3.setTitle(self.Answers[2], forState: UIControlState.Normal)
                        self.Button4.setTitle(self.Answers[3], forState: UIControlState.Normal)
                    }
                } else {
                    NSLog("Something is wrong with the find request, dude.  Sorry. %@", error)
                }
            }
        } else {
            NSLog("Something is wrong with the count request, dude.  Sorry. %@", error)
        }   
    }
}
Run Code Online (Sandbox Code Playgroud)

关于如何摆脱这个错误的任何想法?为什么它之前没有工作呢?谢谢.

use*_*770 2

好吧,一个错误最终导致了另一个错误,但我终于解决了......这基本上是语法(我猜也是转换错误,但本质上是转换中的语法错误......我猜......这里有一个问号,那里有一个感叹号......我是一个新手,所以我真的不知道,只是通过尝试和错误来获得)但这是有效的:

  func CallData() {
        var countQuery = PFQuery(className: "QandA")
        countQuery.countObjectsInBackgroundWithBlock { (count: Int32, error: NSError?) -> Void in
            if (error == nil) { let randomNumber = Int(arc4random_uniform(UInt32(count)))
                var query = PFQuery(className: "QandA")
                query.skip = randomNumber; query.limit = 1
                query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in
                    if (error == nil) {

                        var object: AnyObject = objects![0]
                        self.Question = object ["Question"] as! String!
                        self.Answers = object ["Answers"] as! Array!
                        self.Answer = object ["Answer"] as! String!
                        if (self.Answers.count > 0) {
                            self.QuestionLabel.text = self.Question
                            self.Button1.setTitle(self.Answers[0], forState: UIControlState.Normal)
                            self.Button2.setTitle(self.Answers[1], forState: UIControlState.Normal)
                            self.Button3.setTitle(self.Answers[2], forState: UIControlState.Normal)
                            self.Button4.setTitle(self.Answers[3], forState: UIControlState.Normal) }
                    } else { 

                        NSLog("Something is wrong with the find request, dude. Sorry. %@", error!) 
                    } 
                }
            } else { 
                NSLog("Something is wrong with the count request, dude. Sorry. %@", error!) 
            } 
        } 
    }
Run Code Online (Sandbox Code Playgroud)

  • 那么您更新到 Xcode 6.3 和 Swift 1.2 时甚至没有费心阅读发布说明来了解 Swift 1.2 中的更改?这看起来很愚蠢。 (2认同)