我剛接觸網絡,Xcode和Parse,並且我只是遵循YouTube教程,但由於某些原因代碼無法運行。這裏是。使用Swift從Parse中檢索對象1.2
func CallData(){
var query : PFQuery = PFQuery(className: "QuestionsAndAnswers")
query.getObjectInBackgroundWithId("DZfARcuav8"){
(ObjectHolder : PFObject!, error : NSError!) -> Void in
if (error == nil){
self.Question = ObjectHolder["Question"] as! String
self.Answers = ObjectHolder["Answers"] as! Array
self.Answer = ObjectHoler["Answer"] as! String
if (self.Answers.count > 0){
self.QuestionLabel.text = self.Question
self.Button1.setTitle(self.Answers[0], forState: UIControlState.Normal)
self.Button1.setTitle(self.Answers[1], forState: UIControlState.Normal)
self.Button1.setTitle(self.Answers[2], forState: UIControlState.Normal)
self.Button1.setTitle(self.Answers[3], forState: UIControlState.Normal)
}
}
else{
NSlog("There is something wrong")
}
}
}
錯誤消息說
不能援引 'getObjectInBackgroundWithId' 類型的參數「(字符串,(PFObject,NSError)! - >無效)
那麼,Parse文檔說這個方法看起來像什麼? – nhgrif
他使用Swift 1.2。解析文檔是爲1.1 – nick9999
那麼,Swift試圖自動完成它到什麼? – nhgrif