V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
Buffer2Disk
V2EX  ›  iDev

关于 NSUserDefaults 的使用

  •  
  •   Buffer2Disk · 2019-08-20 13:09:08 +08:00 · 5685 次点击
    这是一个创建于 1703 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,使用的环境是 OSX 10.14.6

    使用 NSUserDefaults 存储了一些数据到 plist 文件,

    然后使用 cleanMyMac 卸载了该软件(.app 文件 和 .plist 文件都被清除)

    然后再次安装的时候,发现该软件竟然能够自动读取出来之前存储的数据

    但是如果此时重启了电脑的话,这些数据就被清理掉了。

    相同的操作在 OSX 10.12 上,清空数据重新安装,再打开后默认就是空的

    请问这是 NSUserDefaults 的什么原理呢? 有没有什么办法不重启,彻底清理掉存储的数据呢?

    3 条回复    2019-09-09 17:27:08 +08:00
    Delon
        1
    Delon  
       2019-08-20 16:29:59 +08:00
    killall cfprefsd
    终结此贴
    Buffer2Disk
        2
    Buffer2Disk  
    OP
       2019-08-21 09:49:07 +08:00
    @Delon 能介绍的详细一点嘛?比如这是 NSUserDefaults 的什么原理呢?
    wellcheng
        3
    wellcheng  
       2019-09-09 17:27:08 +08:00
    NSUserDefaults 本质就是 plist 文件,但是会在内存里有一份缓存
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3751 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:26 · PVG 18:26 · LAX 03:26 · JFK 06:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.