I don't know if anyone else has experienced this, but I have an app I'm building and it was working just fine. Then I stupidly allowed mac to install and xcode update.  Next thing I know, I open the project and the build fails with 21 errors.  I have fixed 20 of them. Incidentally, anyone else finding this issue with PF_Nullability errors, check this out.
That worked for 20 errors, but the last one is in a function that was working correctly.  In this function, I query a data class on parse.com and get a random object to populate variables in my view controller/app/whatevers.  I am putting the function below so you can see the whole thing, but this is the erroneous line:
 countQuery.countObjectsInBackgroundWithBlock { (count: Int32, error: NSError!) -> Void in
There error: cannot invoke 'countobjectsinbackgroundwithblock' with an argument list of type '((Int32, NSError!) - Void in)'
Here is the whole function and here's to hoping it's just a syntax thing like the other 20 fixes:
     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)
        }   
    }
}
Any ideas on how to get rid of that error? Why it's not working now when it did work before? Thank you.
Well, one error eventually led to another, but I finally got it worked out ... it was basically syntax (casting errors also, I guess, but essentially syntax errors in the casting ... I guess ... a question mark here, an exclamation point there ... I'm a newb, so I really have no idea, just getting by with trial and error) but here is what worked:
  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!) 
            } 
        } 
    }
Why don't you just:
I use this approach so Xcode is always the last one. That way I can build old projects just switching to the right Xcode (I put all icons on Dock).
Note: this is a workaround to your main problem. In the near future you should transition to Xcode 6.3 & Swift 1.2, but in the meantime you can build again
Download the last version of Parse to fixed this problem.
https://www.parse.com/docs/downloads/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With