简体   繁体   English

开始使用Core Data for iPhone?

[英]Getting started in Core Data for iPhone?

I want to implement Core Data into my iPhone app. 我想在我的iPhone应用程序中实现Core Data。 So what is the best way to learn Core Data specifically for the iPhone? 那么,专门为iPhone学习核心数据的最佳方法是什么? I have 4ish hours that i can devote to this today, so ideally I would be competent enough to add this (however slightly) into my app. 今天我有4个小时可以投入到这个,所以理想情况下,我有足够的能力将这个(但稍微)添加到我的应用程序中。

The only way i retain data now is through NSUserDefaults, just so that when the app is closed and reopened, their data is still there. 我现在保留数据的唯一方法是通过NSUserDefaults,这样当关闭并重​​新打开应用程序时,他们的数据仍然存在。 I want to give the user the ability to save sets of data, read them, edit them, delete them, etc. 我想让用户能够保存数据集,读取数据,编辑数据,删除数据等。

Getting Started with Core Data in the iPhone Dev Center did the trick for me. iPhone开发中心的核心数据入门为我做了诀窍。 :-) :-)

No, seriously, it might seem like obvious advice, but that one-page document lays out a nice strategy for which documents and tutorials to read and in which order. 不,严肃地说,它看起来似乎是明显的建议,但是这个单页文档提供了一个很好的策略,可以阅读哪些文档和教程以及以何种顺序阅读。 Once you work through the first tutorial it recommends, the weird terminology will feel a lot less weird. 一旦你完成它推荐的第一个教程,这个奇怪的术语就会感觉不那么奇怪了。

If you don't already know about this, this is very useful: 如果您还不知道这一点,这非常有用:

Core Data Tutorial for iPhone OS 适用于iPhone OS的核心数据教程

Two books that are great references for Core Data are "Core Data: Apple's API for Persisting Data on Mac OS X" by Marcus Zarra and "iPhone SDK Development" by Bill Dudney and Chris Adamson. 两本对核心数据有很好参考的书是Marcus Zarra的“核心数据:Apple Mac OS X上持久数据的API”和Bill Dudney和Chris Adamson的“iPhone SDK开发” Both walk you through sample code for handling Core Data on the iPhone, with slightly different perspectives on the framework. 两者都引导您完成在iPhone上处理Core Data的示例代码,对框架的看法略有不同。 The Core Data book provides the best overall reference on the subject that you'll find, outside of Apple's own documentation. 在Apple自己的文档之外,核心数据手册提供了有关该主题的最佳整体参考。

Additionally, if you purchase the iPhone video track from this year's WWDC, the presentations "Introduction to Core Data on iPhone" and "What's New in Core Data" are great resources. 此外,如果您从今年的WWDC购买iPhone视频曲目,“iPhone上的核心数据简介”和“核心数据中的新功能”这些演示文稿都是很好的资源。 ADC Select members also have access to Core Data presentations from older WWDCs, including ones that explain the fundamental concepts of the framework and how to tune the performance of your Core Data application. ADC Select成员还可以访问旧版WWDC的核心数据演示文稿,包括解释框架基本概念以及如何调整Core Data应用程序性能的演示文稿。

Make sure you don't stop after the first document - Core Data Turorial for iPhone OS is excellent but then I tried to change the model and everything crashed with fairly cryptic error messages. 确保你没有在第一个文件后停止 - 用于iPhone OS的Core Data Turorial非常出色,但后来我尝试更改模型,所有内容都因相当神秘的错误消息而崩溃。 Getting Started with Core Data is the next place to go. Core Data入门是下一个去处。 Unless you read the sections on versioning the data model you will probably run into big problems as soon as you start to adapt the example code for your own use. 除非您阅读有关数据模型版本控制的章节,否则只要您开始调整示例代码以供自己使用,就可能会遇到大问题。

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

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