我有一个类POST,具有以下结构:
> text(String)
>图像(PFFile)
> LikesUsers(String of String)
> LikesCount(Int)
>从(发布到用户的指针)
如果用户(已登录)喜欢帖子.我只是递增喜欢并将用户的Objectid添加到数组中
例如:User-2喜欢User-1的帖子.
PostObject.incrementKey("Likes") PostObject.addObject((PFUser.currentUser()?.objectId)!,forKey: "LikesUsers") PostObject.saveEventually()
问题在这里.我不能保存PostObject,只要它有一个指向另一个用户的指针(比登录)我收到错误:
User cannot be saved unless they have been authenticated via logIn or
signUp
那么如何防止保存ParSEObject Children(“From”)
我不想使用CloudCode,我希望保持简单并使用SaveEventually来获得更好的用户体验.
解决方法
When you save an object with a pointer,Parse looks at the entirety of the object and saves the fields that are “dirty” (changed since last save). It also inspects all the objects being pointed to by pointers. If your object has a pointer to PFUser and the instance of the PFUser is “dirty”,then Parse will save the object and then attempt to save the instance of the PFUser as well. My hypothesis is that somewhere in your code you are setting a value on a user and then not saving the user. This,I suspect,is the source of your error. Go through your code and look for anywhere you set a PFUser instance and make sure there’s a corresponding save. If you can’t find it at first glance,be sure to check all blocks and ensure that you are not asynchronously dirtying a user and subsequently trying to save it.
您是否尝试对发布帖子的用户进行任何更改?