获取用户作为指针时访问用户名 属性 时出现 PFUser 错误
Getting PFUser error when accessing username property when getting user as pointer
出现此错误:
'NSInternalInconsistencyException', reason: 'Key "username" has no data. Call fetchIfNeeded before getting its value.'
我有一个关节 class,其中包含 PFUser
作为指针。当我从联合 class 获得一个用户时,它只有预期的指针,但这种情况失败并导致上述错误:
if (user.username != nil) {
username = user.username ?? "no username"
}
/** THE ACCESSING property
The username for the `PFUser`.
*/
@property (nullable, nonatomic, strong) NSString *username;
这可能有两个原因:
- 在您尝试检索的用户上设置了 ACL,因此它
不是 retrieved.So 请检查用户对象上的 ACL。
- 您没有在查询中使用 .includeKey() 方法。为了
includeKey() 请查看下面的指南。
出现此错误:
'NSInternalInconsistencyException', reason: 'Key "username" has no data. Call fetchIfNeeded before getting its value.'
我有一个关节 class,其中包含 PFUser
作为指针。当我从联合 class 获得一个用户时,它只有预期的指针,但这种情况失败并导致上述错误:
if (user.username != nil) {
username = user.username ?? "no username"
}
/** THE ACCESSING property
The username for the `PFUser`.
*/
@property (nullable, nonatomic, strong) NSString *username;
这可能有两个原因:
- 在您尝试检索的用户上设置了 ACL,因此它 不是 retrieved.So 请检查用户对象上的 ACL。
- 您没有在查询中使用 .includeKey() 方法。为了 includeKey() 请查看下面的指南。