每次归档时NSKeyedArchiver都会覆盖整个文件吗? [英] Does NSKeyedArchiver overwrite the entire file every time you archive?

查看:530
本文介绍了每次归档时NSKeyedArchiver都会覆盖整个文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储各种类型的数据,并在不同时间从我的应用程序的不同部分更新它。我的印象是我可以使用NSKeyedArchiver来执行此操作,并在必要时使用适当的密钥更新部分数据......就像数据库一样。每次归档时,NSKeyedArchiver似乎都会覆盖整个文件。

I need to store various types of data and update it from different parts of my application at different times. I was under the impression I could use NSKeyedArchiver to do this and just update parts of the data using the appropriate key when necessary...much like a database. It seems that NSKeyedArchiver overwrites the entire file every time you archive.

我是否正确,因为NSKeyedArchiver会覆盖整个文件,如果有的话,是否有建议你处理这个问题的策略(除了使用SQLLite或CoreData..I)在下一个版本中可能需要升级到此版本。我可以将数据分成不同的文件,但这似乎很多工作。

Am I correct in that NSKeyedArchiver overwrites the entire file and if so, is there a strategy you would suggest for dealing with this (other than using SQLLite or CoreData..I'll probably have to upgrade to this for the next release). I can separate out the data into different files but that seems like a lot of work.

推荐答案

是的,NSKeyedArchiver替换了数据磁盘及其数据。做你想做的事情可能会采用某种数据库解决方案,但不一定是SQLite。您的数据集有多大?重写整篇文章的速度慢吗?

Yes, NSKeyedArchiver replaces the data on disk with its data. To do what you want will probably take SOME sort of database solution, though not necessarily SQLite. How large is your data set? Is re-writing the whole thing that slow?

这篇关于每次归档时NSKeyedArchiver都会覆盖整个文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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