加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – NSUserDefaults日志中的错误

发布时间:2020-12-15 01:55:15 所属栏目:百科 来源:网络整理
导读:我在日志中收到一些错误消息 [User Defaults] Failed to write value for key GameId in CFPrefsPlistSource0x1740faf00 (Domain: xxx.xxxxxx,User: kCFPreferencesCurrentUser,ByHost: No,Container: (null)): Path not accessible,switching to read-only[
我在日志中收到一些错误消息

[User Defaults] Failed to write value for key GameId in CFPrefsPlistSource<0x1740faf00> (Domain: xxx.xxxxxx,User: kCFPreferencesCurrentUser,ByHost: No,Container: (null)): Path not accessible,switching to read-only
[User Defaults] attempt to set <private> for key in <private> in read-only (due to a previous failed write) preferences domain CFPrefsPlistSource<0x1740faf00> (Domain: xxx.xxxxxx,Container: (null))

是什么原因造成的?

这就是我使用NSUserDefaults的方式:

- (NSString *)gameId
{
    if (_gameId)
        return _gameId;

    _gameId = [[NSUserDefaults standardUserDefaults] objectForKey:@"GameId"];
    return _gameId;
}

- (void)setGameId:(NSString *)aGameId
{
    _gameId = aGameId;
    [[NSUserDefaults standardUserDefaults] setObject:_gameId forKey:@"GameId"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

解决方法

很多人在Xcode 8上发现了这个问题。

“因为听起来很疯狂,尝试重新启动手机和主机,有时Xcode可能会因为理由而被卡住,只有重启有帮助。

使用Xcode 8.1 Beta构建,您将看到相同的警告,但您也将获得该值。 “

参考:https://forums.developer.apple.com/thread/51348

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读