我在使用 NSUserDefaults 时收到 SIGABRT
以下行有时会抛出 SIGABRT:
[[NSUserDefaults standardUserDefaults] Synchronize];
我不知道为什么会这样。 顺便说一句,该应用程序是多线程的。
The following line sometimes throws SIGABRT:
[[NSUserDefaults standardUserDefaults] synchronize];
I have not idea why it happens.
By the way, the app is multithreaded.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSUserDefaults 是线程安全的,这不是问题。您在默认值中过度释放了某些对象,并且同步在找到它时崩溃了。
NSUserDefaults is thread safe, that's not the problem. You are over releasing some object in your defaults and synchronize is crashing when it finds it.
如果您在首选项上添加了键值观察器并且未实现
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void * )语境
This can also happen if you added a Key Value Observer on a preference and did not implement
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context