MacOS X:删除应用程序后删除plist文件 [英] MacOS X: Remove plist file when the app is removed

查看:106
本文介绍了MacOS X:删除应用程序后删除plist文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在启动应用程序时显示许可证表格,但应仅在应用程序首次启动时显示.不总是.因此,我尝试将标志存储在plist或用户默认值中,但是在删除应用程序(移至垃圾箱)后,plist或userdefaults并未从系统中删除,因此我无法完成我的任务.

I am showing a license form at app startup, but it should be shown only at the first time the app launched. Not always. So, i tried to store a flag in plist or user defaults, but upon the app removing(move to trash), plist or userdefaults is not getting removed from system, thus i'm not able to achieve my task.

这就是我在下面尝试过的事情,

This is what i have been trying below,

我正在将标志存储在plist文件中,并在应用程序启动期间将文件保存在(文档目录中),因此下次,我可以从那里读取信息,并确定应用程序是否首次运行.我在这里失败了,因为即使该应用程序也已从系统中删除(移至垃圾箱),我也无法删除此plist文件.

I am storing a flag in plist file and save the file(in Documents directory) during App launch, so next time , i can read from there and find out whether the app is running first time or not. I am failing here, because even the app is removed(move to trash) from system, i am not able to remove this plist file.

我也尝试在NSUserDefaults中设置一个标志,但是在删除该应用程序并再次构建并启动该应用程序之后,它仍然保留我存储的先前值.我想知道,从系统删除应用程序后,NSUserDefaults不会被删除吗?

I tried to set a flag in NSUserDefaults too, but after deleting the app and build again and launch the app, it still persists the previous value i stored. I am wondering, NSUserDefaults doesn't get deleted when app is deleted from system?

NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];        
    [ud setObject:@"1" forKey:@"APPLAUNCHED"]; // store user default
    [ud synchronize];

有人可以建议吗?

谢谢.

推荐答案

删除应用程序时,用户默认值和应用程序沙箱都不会自动删除.我认为没有办法.

Neither user defaults nor the application sandbox get automatically removed when the application is deleted. I think there's no way to do that.

这篇关于MacOS X:删除应用程序后删除plist文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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