有什么方法可以预填充核心数据? [英] Any way to pre populate core data?

查看:33
本文介绍了有什么方法可以预填充核心数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在创建一个列表应用程序并用核心数据支持它.

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.

这篇关于有什么方法可以预填充核心数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆