【问题标题】:Getting PFUser error when accessing username property when getting user as pointer获取用户作为指针时访问用户名属性时出现PFUser错误
【发布时间】:2021-01-17 00:24:35
【问题描述】:

收到此错误:

'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;

【问题讨论】:

    标签: ios objective-c parse-platform back4app


    【解决方案1】:

    发生这种情况的原因有两个:

    • 在您尝试检索的用户上设置了 ACL,因此它 未检索到。因此请检查您在用户对象上的 ACL。
    • 您的查询没有使用 .includeKey() 方法。为了 includeKey() 看看下面的这个指南。

    https://docs.parseplatform.org/ios/guide/

    【讨论】:

    • 是的,就我而言,它是 includeKey。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多