gpt4 book ai didi

swift - getObjectInBackgroundWithID 用于解析但在 Swift 中出现 "cannot invoke with argument type"错误

转载 作者:搜寻专家 更新时间:2023-11-01 05:39:38 27 4
gpt4 key购买 nike

<分区>

所以我试图从 Parse 获取一个对象,它给我一个关于可选的错误,我不太明白。该错误与 getObjectInBackgroundWithId 部分有关,我不太明白为什么我的解包不起作用。

import UIKit
import Parse

class ViewController: UIViewController {

var question: String!
var answers: [String]!
var answer: String!


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.



}

func CallData() {
var query : PFQuery = PFQuery(className: "QuestionsAndAnswers")
query.getObjectInBackgroundWithId("myParseCode") {
(ObjectHolder : PFObject?, error : NSError?)-> Void in
// error is here^^
if (error == nil) {
self.question = objectHolder["Question"] as? String
self.answers = objectHolder["Answers"] as? Array
self.answer = objectHolder["Answer"] as? String

if (self.answers?.count > 0) {
self.questionLabel.text = self.question
}

} else {
println("Theres been an error")
}

}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.

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