Core Data内容可以直接编辑吗?
我已经使用 Core Data 大约一周了,并且非常喜欢它,但一个小问题是设置默认值需要经过并设置一个临时接口来加载数据,一旦我完成了,我就将其取消播种的数据。有什么方法可以编辑表中的值,就像如何使用 phpMyAdmin 操作 MySQL 数据库中的值一样?或者,如果没有检测到 storedata XML 文件,是否有办法编写一个函数来从 Numbers 电子表格之类的东西导入种子值?
I've been using Core Data for about a week now, and really loving it, but one minor issue is that setting default values requires going through and setting up a temp interface to load the data, which I then do away with once I have the data seeded. Is there any way to edit values in a table, like how you can use phpMyAdmin to manipulate values in a MySQL database? Alternately, is there a way to write a function to import seed values from something like a Numbers spreadsheet if it doesn't detect the storedata XML file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于您的第一个问题,您可以直接编辑该文件,但强烈建议您不要这样做。如何编辑它完全取决于您选择的商店类型。
当然,关于导入或设置预生成的数据:您可以编写代码来手动将实体实例插入到托管对象上下文中。 文档。此外,如果您有大量数据要导入,甚至还有一个关于如何高效地执行此操作。
For your first question, you could edit the file directly but it's highly recommended you don't. How to edit it depends entirely on the store type you selected.
Regarding importing or setting up pre-generated data, of course: you can write code to manually insert entity instances into your Managed Object Context. There's a dedicated section on this very topic in the documentation. Further, if you have a lot of data to import, there's even a section on how to do this efficiently.
Xcode 有 一种为数据模型创建快速而肮脏的界面的方法。您只需将数据模型文件拖到界面生成器的窗口中,它就会自动为您生成一个界面。这使您可以查看数据,而无需启动并运行整个应用程序。
Xcode has a means of creating a quick and dirty interface for a data model. You just drag the data model file into a window in interface builder and it autogenerates an interface for you. This lets you view the data without having to have your entire app up and running.