删除plist文件不会重置macOS 10.9+上的应用 [英] Deleting plist file does not reset app on macOS 10.9+

查看:114
本文介绍了删除plist文件不会重置macOS 10.9+上的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在10.9上开发Cocoa应用程序时,我注意到,如果我转到~/Library/Preferences并删除我的应用程序的plist文件(以重置它),则在下一次构建和运行时,该应用程序的行为就像plist文件从未被删除过.

While developing a Cocoa application on 10.9, I have noticed that if I go to ~/Library/Preferences and delete the plist file for my app (to reset it), on the next build-and-run, the app behaves as if the plist file had never been deleted at all.

我花了很长时间来追查为什么会发生这种情况,而我在SO上没有看到有关此问题的答案,所以我正在写这个问题并亲自回答以帮助他人.

It took me a long time to track down why this happens and I did not see a question/answer about it on SO, so I'm writing this question and answering it myself to help others.

推荐答案

在10.9上,系统正在对首选项进行更强大的缓存".删除plist文件后,我启动了活动监视器并强制杀死了"cfprefsd"进程.注意:有多个进程正在运行该名称,并且您只想杀死以您自己的用户身份运行的进程.不要杀死以root身份运行的人.

On 10.9, the system is doing some more robust "caching" of preferences. After deleting the plist file, I fired up Activity Monitor and force-killed the "cfprefsd" process. Be careful: there are multiple processes with this name running and you only want to kill the one running under your own user; do not kill the one running as root.

这样做似乎刷新了首选项缓存,并且在我的应用程序的下一次运行中,我得到了从头开始的原始启动.

Doing this seems to flush the preferences cache and on the next run of my app, I get a pristine start-from-scratch launch.

如下所述,在命令行中使用defaults delete [your bundle identifier]似乎也可以消除缓存问题.我在这方面取得了不同的成功.

As reported below, using defaults delete [your bundle identifier] at the command line also appears to eliminate the caching issue. I've had mixed success with this.

这篇关于删除plist文件不会重置macOS 10.9+上的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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