5.2 Intro to Core Data
In this lesson, we are going to introduce the basic concept of what Core Data is. Think of Core Data as a way to make data persist within your application after it has closed, and being able to retrieve it any time that is necessary throughout the lifecycle of your app.
1.Introduction3 lessons, 06:16
2.Setting Up the Project5 lessons, 1:00:13
3.Processing Data3 lessons, 37:52
4.Interacting With the UI6 lessons, 41:27
5.Core Data6 lessons, 44:36
6.Conclusion1 lesson, 02:47
5.2 Intro to Core Data
At this point in the course, we have built a rather respectable app. We can now add feeds or allow the user to add feeds to our application. It will download the data, parse out the articles, and create a nice little navigational hierarchy from feeds to articles, and then ultimately viewing that article. We've added in a nice little pop over view so that we can have the user enter in some data and then we've been able to. Unwind that segue back to the feeds view controller, the feeds table view controller, and pass data back so that we can add things to it. But what we noticed in the last lesson, was that once we run our application and add several feeds to it, the minute we close down our application and bring it back up again, we are left with an empty list of feeds and that is a problem. The reason that's a problem is because the user is now going to have to enter in or re-enter their feeds every single time they want to see the latest articles and read them as well. So in this section, we're gonna cover a rather interesting and rather important topic, within the iOS programming environment, and that is core data. Now if you've never heard of core data, and even if you have, I definitely encourage you to head over to the iOS developer library, and pick through the core data programming guide. Now, there's an awful lot of information here, a lot of very good information, but it's not very beneficial for you to just read from beginning to end. So I definitely recommend for you to pick through here, read some of the basics, understand some of the fundamentals, and then try to actually start to put things into play within your own application. So I'm not gonna go through the process of reading all of this information to you, I'm just gonna summarize it. So very basically, core data is a generalized mechanism or framework, if you will, that's going to allow you to per, persist information in a rather structured, object graph kind of a way. So that you can persist it beyond the life cycle of your applications, so I can save this physically somewhere within my device and then I can retrieve it later on. Now this is going to sound remarkably similar to say, a relational database management system or something along those lines. It is definitely not that, it does not work the same way. You're not executing structured queries and creating these elaborate relationships with keys and indexes and all those types of things. You don't do that. It's a very simplified version of that. Now, if you begin to read a little bit further into this,you will find that on the iOS platform, core data is a framework, and underneath at the very bottom, you are actually interacting with SQL lite, even though we are not using it in such a relational way; even though that would start to bring up premonitions or at least thoughts of it being a relational system. So, having said that, what we're basically gonna be working with within core data is something called a context, which is going to represent your interactions into the world of persistence and getting data out of that persistence. And also working with things called entities which are going to be those objects that you're gonna store. And also some relationships and those relationships are gonna allow us to tie different entities together in either a one to one, or one to many, or many to one relationship that you maybe familiar with if you've done other sort of kind of relational database programming in the past. But you're also gonna be able to create those like child to parent relationships, which is what we're gonna do in this application, when we start working with feeds and our articles are being able to persist those into core data. So, that's the basics of it. I definitely urge you to read through some of this and pick through it to understand the basic concepts. And in the next several lessons, I'm going to show you those basic concepts, so you can begin putting them into practice immediately.