保存具有User as Reference的Parse对象

时间:2016-02-11 14:08:49

标签: swift parse-platform

我尝试使用User作为指针保存 Parse 对象,但我收到此错误:

  

Caught" NSInternalInconsistencyException"有理由"用户不能   除非已通过logIn或signUp":

进行身份验证,否则会保存

这是我的代码:

 var Post : PFObject?
    var objectid : String?

 let query = PFQuery(className: "Feed")
    query.getObjectInBackgroundWithId(objectid!) {
        (post: PFObject?, error: NSError?) -> Void in
        if error == nil && post != nil {
            self.Post = post
        } else {
            print(error)
        }
    }
func comment() {

let Comment = PFObject(className:"Comments")
        Comment["Text"] = CommentField.text
        Comment.setObject(Post!, forKey: "Post") // 
        Comment["User"] = PFUser.currentUser()!
        Comment.saveInBackgroundWithBlock {
            (success: Bool, error: NSError?) -> Void in
            if (success) {
                self.CommentField.text = ""
                self.Refresh()
            } else {
                // There was a problem, check error.description
            }
}

首先我试图从Parse中检索有关的帖子,当用户想要评论时,我创建了这个评论对象并保存它,帖子对象将用户作为参考

enter image description here

0 个答案:

没有答案