Any way to pre populate core data?(有什么方法可以预填充核心数据?)
问题描述
我一直在创建一个列表应用程序并用核心数据支持它.
I've been creating a list app and backing it with core data.
我想要一个包含 10 个机场项目的默认列表,这样用户就不必从头开始.
I would like to have a default list of say 10 airport's items, so that the user doesn't have to start from scratch.
有没有办法做到这一点?
Is there any way to do this?
感谢任何帮助.提前致谢.
Any help is appreciated. Thanks in advance.
推荐答案
这是最好的方法(并且不需要 SQL 知识):
使用与 List 应用程序相同的对象模型创建一个快速的 Core Data iPhone 应用程序(甚至是 Mac 应用程序).编写几行代码,将您想要的默认托管对象保存到存储中.然后,在模拟器中运行该应用程序.现在,转到 ~/Library/Application Support/iPhone Simulator/User/Applications.在 GUID 中找到您的应用程序,然后将 sqlite 存储复制到您的 List 应用程序的项目文件夹中.
Here's the best way (and doesn't require SQL knowledge):
Create a quick Core Data iPhone app (Or even Mac app) using the same object model as your List app. Write a few lines of code to save the default managed objects you want to the store. Then, run that app in the simulator. Now, go to ~/Library/Application Support/iPhone Simulator/User/Applications. Find your application among the GUIDs, then just copy the sqlite store out into your List app's project folder.
然后,像在 CoreDataBooks 示例中那样加载该存储.
Then, load that store like they do in the CoreDataBooks example.
这篇关于有什么方法可以预填充核心数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有什么方法可以预填充核心数据?


- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01