I am using Parse SDK in Swift and trying to create a new vote Object, then save a pointer to the current user.
I get the following error - [Error]: can't add a non-pointer to a relation (Code: 111, Version: 1.7.1).
func createVoteObject(row: Int, quest: PFObject) {
var vote = PFObject(className: "Votes")
vote["user"] = PFUser.currentUser()
vote.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if error != nil {
println("Error saving vote object: \(error!)")
} else {
Do something else
}
}
}
I have no problem adding other properties.
I get the same issue with this function
func saveVoteToUserObject(vote: PFObject, quest: PFObject) {
if let currentUser = PFUser.currentUser() {
var userToVoteRelation = currentUser.relationForKey("votes")
userToVoteRelation.addObject(vote)
var userToQuestRelation = currentUser.relationForKey("votedOnQuests")
userToQuestRelation.addObject(quest)
currentUser.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if error != nil {
println(error)
} else {
println("Successfully saved vote to User object")
}
}
}
}
Any thoughts?