本文介绍了更改另一个 PFuser 对象中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的游戏中,一个用户可以对另一个用户造成伤害,并拿走他们的一些金币.gold 变量存储在其他用户的 PFUser 对象中.一个用户如何更改存储在其他用户 PFUser 对象中的金币值?

In my game, a user can cause damage to another user, and take some of their gold. The gold variable is stored in the other users PFUser object. How can one user change the value for the gold that is stored in the other users PFUser's object?

推荐答案

您无法保存或删除未经身份验证的 PFUser.实现该功能的方法是为公共读/写用户变量设置一个单独的类

You can not save or delete non-authenticated PFUsers. The way to implement that functionality is to set up a separate class for public read/write user variables

来自解析文档 -

用户对象的安全

PFUser 类默认是安全的.存储在 PFUser 中的数据可以只能由该用户修改.默认情况下,仍然可以读取数据由任何客户.因此,某些 PFUser 对象已通过身份验证并且可以已修改,而其他则是只读的.

The PFUser class is secured by default. Data stored in a PFUser can only be modified by that user. By default, the data can still be read by any client. Thus, some PFUser objects are authenticated and can be modified, whereas others are read-only.

具体来说,您不能调用任何保存或删除方法,除非 PFUser 是使用经过身份验证的方法获得的,如登录或注册.这确保只有用户可以更改他们的自己的数据.

Specifically, you are not able to invoke any of the save or delete methods unless the PFUser was obtained using an authenticated method, like logIn or signUp. This ensures that only the user can alter their own data.

这篇关于更改另一个 PFuser 对象中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 21:02