简体   繁体   English

将Core Data For Storage用于现有的Iphone项目?

[英]Use Core Data For Storage for an existing Iphone project?

According to the Apple Core Data Tutorial, in order to use Core Data you have to: 根据Apple Core Data Tutorial,为了使用Core Data,您必须:

In the Options section, select the switch to use Core Data for storage. 在“选项”部分中,选择要使用Core Data进行存储的开关。

How do it for an existing project? 对现有项目有何看法? Do you have to import some files? 你必须导入一些文件吗? Can that setting be activated later on? 以后可以激活该设置吗?

Thanks 谢谢

Selecting that option automatically adds the CoreData.framework, an empty data model, and a little bit of Core Data code to the AppDelegate and View Controllers classes. 选择该选项会自动将CoreData.framework,空数据模型和一些核心数据代码添加到AppDelegate和View Controllers类。

If you want to start using CoreData in your existing project; 如果要在现有项目中开始使用CoreData;

1) Add CoreData.framework to the project. 1)将CoreData.framework添加到项目中。

2) Do "New File", go to "Resource", and add a new "Data Model" to the project. 2)执行“新建文件”,转到“资源”,并向项目添加新的“数据模型”。

3) Create a temporary new project (check that use Core Data box). 3)创建一个临时的新项目(检查是否使用Core Data框)。 Then, you can look and see the Core Data-related code that it added to those template files. 然后,您可以查看并查看它添加到这些模板文件中的与Core Data相关的代码。 Carefully merge that stuff into your existing AppDelegate. 小心地将这些东西合并到现有的AppDelegate中。

4) You should be all set to pick up the tutorial from that point. 4)你应该准备好从那一点开始学习教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM