Xcode 6.3 update cause working app to fail – what was working now doesn't

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:

  • How to access camera with swiping gesture?
  • Post dictionary from Swift to PHP
  • tgmath.h doesn't work if modules are enabled
  • UI Tests - isSelected is always returning false
  • iOS 3DES with ECB return half correct data
  • changing the color of image in iphone sdk
  •  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.

    4 Solutions Collect From Internet About “Xcode 6.3 update cause working app to fail – what was working now doesn't”

    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:

    1. Go to https://developer.apple.com/downloads/index.action?name=Xcode (needs developer account) and download Xcode 6.2 DMG
    2. Rename in /Applications current Xcode 6.3 app (it’s called just Xcode) to Xcode-6.3
    3. Mount downloaded DMG, then copy Xcode to Applications.
    4. Xcode now is Xcode 6.2

    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/

    There is a tool in Xcode to help convert your Swift 1.1 to 1.2 – Go to Edit > Convert