我试图创建一些应用程序,我有问题,我有这样的结构,问题和答案。
我的班级:

class QuestionManager{
 var question: String?
 var answerA: String?
 var answerB: String?
 var answerC: String?
 var answerD: String?

}

我的代码:
var questions = [QuestionManager]()
var arrayIndex = 0
let query = PFQuery(className: "test")
query.findObjectsInBackground{ (objects, error) in
if error == nil && objects != nil {
    for object in objects as? [PFObject]{
          self.questions.append(QuestionManager(
          question: object!["question"] as! String,
          answerA: object!["answer1"] as! String,
          answerB: object!["answer2"] as! String,
          answerC: object!["answer3"] as! String,
          answerD: object!["answer4"] as! String

          ))
    }
} else {
    print("Error")
}

使用此代码时,出现错误:
无法使用类型为“(QuestionManager)”的参数列表调用“append”
为什么我会得到这个,错误,也许你会看到我的错误
ios - iOS在按下“下一步”按钮时加载新行表格解析Swift-LMLPHP

最佳答案

替换这个

var questions = [QuestionManager]()
var arrayIndex = 0
let query = PFQuery(className: "test")
query.findObjectsInBackground{ (objects, error) in
if error == nil && objects != nil {
    for object in objects as? [PFObject] {

          let objQuestionManager = QuestionManager()

          objQuestionManager.question = object!["question"] as! String
          objQuestionManager.answerA = object!["answer1"] as! String
          objQuestionManager.answerB = object!["answer2"] as! String
          objQuestionManager.answerC = object!["answer3"] as! String
          objQuestionManager.answerD = object!["answer4"] as! String

          self.questions.append(objQuestionManager)
    }
} else {
    print("Error")
}

关于ios - iOS在按下“下一步”按钮时加载新行表格解析Swift,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51606375/

10-12 12:19