ios - 获取用户作为指针时访问用户名属性时出现PFUser错误
问题描述
收到此错误:
'NSInternalInconsistencyException', reason: 'Key "username" has no data. Call fetchIfNeeded before getting its value.'
我有一个包含PFUser
指针的联合类。当我从联合类中获取用户时,它只有预期的指针,但这种情况失败并导致上述错误:
if (user.username != nil) {
username = user.username ?? "no username"
}
/** THE ACCESSING property
The username for the `PFUser`.
*/
@property (nullable, nonatomic, strong) NSString *username;
解决方案
发生这种情况的原因有两个:
- 在您尝试检索的用户上设置了 ACL,因此没有被检索。所以请检查您在用户对象上的 ACL。
- 您没有在查询中使用 .includeKey() 方法。对于 includeKey(),请查看下面的本指南。
推荐阅读
- javascript - 在解析 HTML 之前等待脚本结束
- laravel - PHP array_map() 总是将我的第一个索引值更改为零值
- c# - 当索引不同步时,如何与另一个数组相比重新对齐数组数据?
- java - Java 在单独的文件中找不到特定方法
- python - Python海龟UnboundLocalError
- python - 如何使用python在maya的活动视图中显示/隐藏项目(?)?
- javascript - 如何保存用户在我的网站游戏上的进度?
- java - 如何在构造函数java中调用初始化char数组的私有方法
- python - 不应在多个会话上烧瓶对象
- jquery - PDF 预览后无法关闭模式