如何将核心数据添加到现有的实用程序应用程序 [英] How to Add Core Data to an existing Utility Application

查看:20
本文介绍了如何将核心数据添加到现有的实用程序应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个几乎完整的实用程序应用程序,但现在我想我真的必须保留数据.

I´ve created an utility Application which is nearly complete, but now I´m on a point were I really have to persist Data.

由于 XCode 在导航或基于窗口的应用程序中仅提供核心数据模板,是否有一种简单的方法可以将核心数据添加到我的应用程序中?我从来没有使用过 Core Data,只需要保存 460 个字符的消息和一个联系人名称,将其作为发送消息的历史记录.

Since XCode provides only Core Data Templates in an Navigation or Window Based App, is there an easy way to add Core Data to my Application? I´ve never worked with Core Data and just have to persist messages with 460 Characters and a contact Name tp it as a history of send Messages.

或者我应该从一个新的基于窗口的应用程序开始,包括.Core Data 并尝试手动构建实用程序/反面部分?

Or should I start with a new Window Based Application incl. Core Data and try to build the Utility / Flipside Part by hand?

有人可以为我推荐适合我情况的最佳做法吗?

Can someone suggest me the best practice for my situation?

推荐答案

您需要将 CoreData 框架添加到目标中,创建数据模型,并实例化 NSManagedObjectModelNSPersistentStoreCoordinatorNSManagedObjectContext 对象.

You'll need to add the CoreData framework to your target, create a data model, and instantiate the NSManagedObjectModel, NSPersistentStoreCoordinator, and NSManagedObjectContext objects.

将核心数据添加到现有应用程序在此 Apple 文档(搜索对于现有应用程序")

Adding Core Data to an existing application is discussed briefly in this Apple document (search for "existing application")

您还应该查看 Apple 教程 以了解什么是涉及.

You should also view the Apple tutorial to get a feel for what is involved.

你也可以考虑只使用 SQLite.

You can always consider just using SQLite as well.

这篇关于如何将核心数据添加到现有的实用程序应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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