iPhone 使用 P 列表保存游戏

发布于 2024-09-15 04:48:46 字数 144 浏览 0 评论 0原文

我目前正在使用 P-List 来保存我正在开发的游戏中的数据。不过我对某件事很好奇。

也许这是一个愚蠢的问题:但是每次我写入P表时,它都会被覆盖吗?如果是这种情况,并且它只是不会自动向其添加(即附加)值,那么那就完美了。

谢谢您的回复。 :D

I am currently using a P-List to save data in a game I'm developing. I'm curious about something though.

Maybe this is a stupid question: but each time I write to the P-List, is it overwritten? If that is the case, and it just doesn't automatically ADD (i.e. appending) values to it, then that would be perfect.

Thank you for your replies. :D

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太傻旳人生 2024-09-22 04:48:46

是的,当您使用 NSDictionary#writeToFile:atomically: 或 NSPropertyListSerialization 中的方法之一编写属性列表时,您的文件将被完全覆盖。

因此,这意味着如果您只想更新其中的单个值,则必须完全读入它,更改该值,然后再次将其写出。

Yes, when you write the property list with either NSDictionary#writeToFile:atomically: or one of the methods in NSPropertyListSerialization then your file will be completely overwritten.

So this means tht if you just want to update a single value in it, that you will have to read it in completely, change the value and then write it out again.

尴尬癌患者 2024-09-22 04:48:46

是的,它被覆盖了。如果你想添加到它,你必须使用 NSMutableArray/NSMutableDictionary 类并保留它,然后添加到它并每次写入文件。

或者,您可以考虑使用核心数据 ...

Yes, it is overwritten. If you want to add to it, you have to use the NSMutableArray/NSMutableDictionary classes and keep it around, then add to it and write the file each time.

Alternatively, you might consider using Core Data...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文