NSUserDefaults日志中的错误 [英] NSUserDefaults errors in logs

查看:317
本文介绍了NSUserDefaults日志中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在日志中收到一些错误消息

I get some error messages in logs

 [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, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null))

造成这种情况的原因是什么?

What does cause this?

这就是我使用的方式 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上的问题。

Lot of people are finding this issue on Xcode 8.

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

"As crazy as it sounds try rebooting phone and host, sometimes Xcode can get stuck for sum reason only restart helps.

构建,您将看到相同的警告,但您也会获得该值。

build with Xcode 8.1 Beta and you will see the same warning, but you will also get the value. "

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

这篇关于NSUserDefaults日志中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆