从 NSKeyedArchvier 中删除数据
我正在使用 NSKeyedArchiver 存储数据。当用户退出我的应用程序时,我想清除我存储的所有数据。我该如何去做呢? [NSKeyedUnarchiver unarchiveObjectWithFile:]
似乎没有删除该文件。
谢谢!
I am storing data with NSKeyedArchiver. When a user logs out of my app, I would like to clear all the data that I have stored. How can I go about doing that? It doesn't appear that [NSKeyedUnarchiver unarchiveObjectWithFile:]
removes the file.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSKeyedArchiver & NSKeyedUnarchiver
仅对您的对象进行编码和解码,以便可以存储和检索它们。如果您将数据存储在文件中,只需删除该文件(使用 NSFileManager )。如果您将数据存储在其他位置(例如 NSUserDefaults、数据库等),那么您需要删除适合存储的数据。NSKeyedArchiver & NSKeyedUnarchiver
only encode and decode your objects so they can be stored and retreived. If you are storing the data in a file, just delete the file (useNSFileManager
). If you are storing data in other places (egNSUserDefaults
, a database, etc) then you need to delete the data as appropriate for the store.