iOS中将数据存储在plist中

发布于 2024-08-06 13:42:36 字数 61 浏览 3 评论 0原文

我想在 plist 文件中存储一些数据。如果我更改 plist 文件中的数据,是否必须重新编译我的应用程序?

I want to store some data in plist file. If I change data in plist file, do I have to recompile my application?

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

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

发布评论

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

评论(3

清晨说晚安 2024-08-13 13:42:36

我不太确定我理解你的问题。这里有一些需要考虑的事情:

  1. 如果您尚未将数据存储在 plist 文件中,并且您的应用程序需要读入它,那么您的应用程序需要知道如何读取(也可能写入)plist文件以及其中数据的格式。为此,您需要重新编译您的应用程序。

  2. 如果您已经有一个应用程序,并且您想进入“包”并修改其中的 plist 文件,那么您将破坏该应用程序,因为该应用程序经过数字签名,如果签名无效,则该应用程序将无法运行。要制作有效的签名,您需要使用 Xcode 或其他一些签名实用程序(我不知道有任何)来重建您的应用程序。这可能并不意味着您的应用程序必须重新编译,但它确实必须“重新构建”。

  3. 如果您计划在应用程序构建后修改此 plist 文件,无论是通过您的应用程序以编程方式还是以其他方式,那么您的应用程序需要从应用程序包外部的某个位置获取此 plist 文件,以解决签名问题。在那里,可以修改或读取它,而不会导致您的应用程序无效。

  4. 如果您想要通过应用程序分发此 plist 文件,请将其放入 Xcode 中的资源文件夹中。在您的应用程序中,检查是否可以在“首选项”或“文档”文件夹中找到该文件,如果没有,请继续将该文件从应用程序包复制到“首选项”或“文档”文件夹中。从那时起,然后使用该副本。

I'm not quite sure I understand your question. Here are some things to think about:

  1. If you haven't yet stored the data in the plist file, and your app needs to read it in, then your app needs to know how to read (and maybe write) the plist file, and the format of the data within it. For that, you'd need to recompile your app.

  2. If you have an app already, and you want to go inside the "package" and modify a plist file in there, then you will be breaking the app since the app is digitally signed and will not run if the signature is invalid. To make a valid signature, you need to rebuild your app using Xcode or some other signing utility (i don't know of any). This might not mean that your app has to recompile, but it does have to "rebuild".

  3. If you plan on modifying this plist file after the app is built, whether programmatically by your app or otherwise, then your app needs to be getting this plist file from someplace outside of your app bundle, to get around the signature issue. There, it can be modified or read without invalidating your app.

  4. If you want a way to distribute this plist file with the app, then put it in your resource folder in Xcode. In your app, check if you can find that file in your Preferences or Documents folder, and if not, then go ahead and copy the file from your app bundle into the Prefs or Documents folder. From then on, then use that copy.

半步萧音过轻尘 2024-08-13 13:42:36

您不必这样做,但如果将 plist 复制到正确的位置是构建过程的一部分(即,如果它位于 Resources 文件夹或其他文件夹中),那么重新编译可能是最简单的方法以便复制修改后的版本。编译器很聪明。它不会重新编译自上次编译以来未更改的内容,因此如果您所做的只是编辑 plist 并重新编译,那么它应该会很快。

除此之外,欢迎您在属性列表编辑器中将其打开并就地修改。

You don't have to, but if copying the plist to its proper location is part of your build process (ie, if it's going in a Resources folder or something), then it's probably easiest to just recompile so that the modified version gets copied. The compiler is smart. It's not going to recompile things that haven't changed since the last compilation, so if all you're doing is editing the plist and recompiling, it should go very quickly.

Other than that you're welcome to just pop it open in Property List Editor and modify it in-place.

已下线请稍等 2024-08-13 13:42:36

是的,要根据 plist 文件的更改查看输出,您必须重新编译它。

Yes, to view the output according to the changes in plist file you have to recompile it.

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