1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Leveraging Core Data to Store Data on iOS

Improvements

Contents

keyboard_tab

The course is part of this learning path

Start course
Overview
Difficulty
Intermediate
Duration
2h 10m
Students
17
Description

This course focuses on a concept known as core data, which will allow us to store our data in a database. We'll then show you how to apply this concept to a real-life app which we will build called Art Book.

Learning Objectives

Learn how to create a local database allowing users to save data on their phones using core data

Intended Audience

This course is intended for beginners who want to learn how to build apps using Swift.

Prerequisites

To the most out of this course, you should have some basic understanding of programming and computer science in general.

Transcript

Hi, within this lecture, we're going to do the rest of the improvements that we have talked about like hiding the save button from the selected details view controller, okay? And maybe disabling the save button until a user chooses an image inside of our ad screen, okay? And also I'm just going to show you how to get some exemplary images in your app. So, let me open the assistant editor because I'm just going to have to define the save button as an outlet. Yes, because we only have the save button as an action but we have to reach its attributes at this point. So, I'm just going to come over here and save save button and make sure that outlet is chosen rather than action and click on ads. And close this and now we're done. So, if we go to details view controller, we can reach save button from any function and we can make it hidden or we can make it disabled. For example, if chosen painting is not empty string, so it means that we're just going to get some values from the core data and in here we don't even need save button. So, if you say save button is enabled, okay, this one is enabled. If you make this false, it means that the button will be shown but it won't be clickable. So, let me show you what I mean. Let me run this, okay? And in the details view controller, when we click on one of the table view items, as you can see it doesn't show right now. It shows actually but we cannot click on it. So, this should be good but maybe we can do is hidden false as well. So, it won't even show, it's hidden true I mean, it won't even show the save button. It will just make it invisible. So, if you go over here you will see that this is now invisible. And in the plus button, in the add button clicked, we can use the is enabled first thing in here unless a user chooses an image, right? So, let's go down. So, if chosen painting is not an empty string, we're doing this. And if it's actually an empty string in the else block, we can come over here and just say save button that is hidden is going to be false because I want it to be visible but I want it to be disabled. So, I'm going to say is enabled false. And once a user chooses an image in the did finish speaking media with info function, I'm going to do save button that is enabled true. So, let's say that save button that is enabled is true, so that this will be only clickable once a user chooses an image. Okay, so this vote will be much more efficient than what we have been doing. As you can see we cannot click on this. So, let's come over here and choose a paintings from this and as you can see now I can click on the save button. And we're done with the app. So, let me show you how you can find some images from online that you can use as a task purpose in your app. So, try to just take this up a little bit as in a real iPhone. As you can see you can close the app anytime you want and you can use this as a real phone. So, let me go to Safari, okay? And let me go to google.com and we're going to just google some arts. So, I believe we can start with Mona Lisa for example, and it's the most basic one. So, our user is going to be visiting Louvre Museum and suppose that he or she sees this Mona Lisa. If you hold onto that, you can add to photos. So, you have to long press on the Mona Lisa or any image, okay, in order to save it to photos. Suppose that our user has just taken the picture of Mona Lisa and then later on she will just add it to our app. So, let's go for a scream by Edvard Munch. Okay, so let's click on this and say add photos and let's go for one or two more paintings. Maybe we can go for Starry Nights, okay, so this is why one go. So, find one and click on that and it doesn't work, I believe this is too big. So, it's not even an image, I believe we are inside of a website. So, let me go to images, okay? Yeah, this one images and find a regular image from here and click on that, long press and say add photos. Maybe we can get some more like Last Supper, okay, so let's go for Last Supper by da Vinci, I believe, yeah? So, Last Supper and just find that one that is good looking for you and add it to your photos. Once you do that, you're good to go, you can just close this down, okay? You can just close this down as well and you can find your own app from this menu and just open it and you can just select the images in your photo album like this. And here you go, you can edit the image, but since we have chosen the original image in the did finish picking media, it won't even going to matter. So, Mona Lisa, the artist, let's say da Vinci and let's say 1850. And I don't know the years of these paintings, I'm just making this up. So, maybe you're better art lover than me so you can find the details and add for real. So, this is Scream, okay, Edvard Munch, and the year will be something like 1900, 1800, okay, and here you go. Let me do one more example. Let's go for Last Supper this time, okay? And this will be Last Supper and the artist will be da Vinci and the year will be 1800 and here you go. Now delete all of this. And here we have our art book. So, let's stop it and play it from the beginning. As you can see we have the related data in our record data and everything seems to be working fine. So, I believe we have learned a lot in this section. So, you have learned how to work with local databases, how to do some improvements on your own app, how to use notification center, how to use gesture recognizer to go and select pictures from the user's library and everything. So, I hope you enjoyed this section. So, let's stop here and go into the next section where we're going to talk about maps.

About the Author
Students
951
Courses
55
Learning Paths
3

Atil is an instructor at Bogazici University, where he graduated back in 2010. He is also co-founder of Academy Club, which provides training, and Pera Games, which operates in the mobile gaming industry.

Covered Topics