将文本从 UITextView 更新到 Plist

发布于 2024-08-19 03:50:15 字数 148 浏览 3 评论 0原文

我有一个 TestData.plist 存储在资源文件夹中,当内容显示在 textview 中时,我希望它是可编辑的,用户可以编辑 textview 上的文本并将其保存到同一个 TestData.plist 文件中。最好的方法是什么?我是 iPhone 开发中的菜鸟。需要帮助请..

I have a TestData.plist stored in the resource folder and when the content is displayed in the textview i want it to be editable in a sense that user can edit and save the text on textview to the same TestData.plist file. what is the best way to do it?I am a total noob in iphone dev. Need help please..

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

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

发布评论

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

评论(1

浮世清欢 2024-08-26 03:50:15

您无法将其保存到同一个 TestData.plist 中。您的应用程序中包含的资源是只读的。

您应该做的是将 TestData.plist 复制到 ~/Documents 目录并在那里保存工作副本。就像您的应用程序启动时一样,执行以下操作:

if ~/Documents/TestData.plist does not exist:
    copy Testdata.plist to ~/Documents/TestData.plist
open ~/Documents/TestData.plist

您可以通过以下方式找到 ~/Documents 目录:

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)

将您的“文档”放在 ~/Documents 中也意味着当用户同步其设备时,iTunes 将对其进行备份。

You cannot save it to the same TestData.plist. Resources included with your app are read-only.

What you should do is copy the TestData.plist to the ~/Documents directory and have the working copy there. Like when your app starts, do the following:

if ~/Documents/TestData.plist does not exist:
    copy Testdata.plist to ~/Documents/TestData.plist
open ~/Documents/TestData.plist

You can find the ~/Documents directory with:

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)

Having your 'document' in ~/Documents also means that it will be backed-up by iTunes when the user synchronizes his or her device.

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