Xcode 6.3更新导致工作应用程序失败 – 现在工作的东西没有

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

这工作20错误,但最后一个是在一个正常工作的function。 在这个函数中,我查询parse.com上的一个数据类,并得到一个随机的对象来填充我的视图controller/app/whatevers发送者的variables。 我正在下面的function,所以你可以看到整个事情,但这是错误的路线:

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

这里是整个函数,这里是希望它只是一个语法的东西,像其他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) } } } 

任何想法如何摆脱这个错误? 为什么现在不工作,以前工作呢? 谢谢。

嗯,最终导致了另一个错误,但我终于find了解决scheme…它基本上是语法(铸造错误也是,我猜,但基本上在铸造语法错误…我猜…这里的问号,那里有一个惊叹号…我是一个新手,所以我真的不知道,只是通过试验和错误)但是这是什么工作:

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

你为什么不只是:

  1. 转到https://developer.apple.com/downloads/index.action?name=Xcode (需要开发者帐户)并下载Xcode 6.2 DMG
  2. 将/ Applications目前的Xcode 6.3应用程序(称为Xcode)重命名为Xcode-6.3
  3. 安装下载的DMG,然后将Xcode复制到应用程序。
  4. Xcode现在是Xcode 6.2

我使用这种方法,所以Xcode始终是最后一个。 这样我可以build立旧的项目只是切换到正确的Xcode(我把所有的图标在Dock上)。

注意:这是您的主要问题的解决方法 。 在不久的将来你应该转换到Xcode 6.3和Swift 1.2,但同时你可以重新构build

下载Parse的最后一个版本来解决这个问题。

https://www.parse.com/docs/downloads/

在Xcode中有一个工具来帮助你的Swift 1.1转换到1.2 – 转到编辑>转换