gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 05:44:13 26 4
gpt4 key购买 nike

我不知道是否还有其他人遇到过这种情况,但我有一个正在构建的应用程序,它运行良好。然后我愚蠢地让mac安装和xcode更新。我知道的下一件事是,我打开项目,但构建失败并出现 21 个错误。我已经修复了其中的 20 个。顺便说一下,任何其他发现此问题的PF_Nullability 错误,check this out .

这对 20 个错误有效,但最后一个错误是在一个正常工作的函数中。在这个函数中,我在 parse.com 上查询一个数据类并获取一个随机对象来填充我的 View 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)'

这是整个函数,希望它只是像其他 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)
}
}
}

关于如何消除该错误的任何想法?为什么它以前工作时现在不工作?谢谢。

最佳答案

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

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

关于ios - Xcode 6.3 更新导致工作应用程序失败 - 现在工作的不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29544623/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com