This is my error message:
Cannot invoke 'getObjectInBackgroundWithId' with an argument list of type '(String, (PFObject!,NSError!) -> Void)'
This is what my code looks like:
func CallData(){
var query : PFQuery = PFQuery(className: "QuestionsandAnswers")
query.getObjectInBackgroundWithId("iXCrgCLKk2"){
(Object : PFObject!, error : NSError!) -> Void in
if (error == nil){
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
}
} else {
NSLog("There is something wrong!")
}
}
}
I have tried changing around the exclamation point/question mark/nothing behind PFObject
and NSError
but nothing works. However, if I make it a question mark behind both PFObject
and NSError
I get a new error message that says:
'AnyObject' is not convertible to 'String!';did you mean to use 'as!' to force downcast?
If I change the code to as!
then I get this error:
Cannot assign immutable value of type 'String!'
Any ideas on how to fix this? Any help is appreciated!