Crash Course: Creating an iOS App | Joshua Bowen | Skillshare

Crash Course: Creating an iOS App

Joshua Bowen

Crash Course: Creating an iOS App

Joshua Bowen

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
20 Lessons (1h 6m)
    • 1. Introduction

    • 2. What we will be building

    • 3. Download Xcode

    • 4. Create a New Project

    • 5. Walkthrough of Xcode Development Environment

    • 6. What is Interface Builder?

    • 7. Create the Main Page in Interface Builder

    • 8. Add Auto Layout

    • 9. Create Custom Table View Cells

    • 10. Connect IB Outlets & IB Actions to the VC

    • 11. Display Items in the Table View

    • 12. Create a New Item

    • 13. Check Off Completed Items

    • 14. Delete Items from the Table View

    • 15. What is Core Data?

    • 16. Create the Item Entity

    • 17. CRUD - Read (Show List of Items)

    • 18. CRUD - Create (Add Items)

    • 19. CRUD - Update (Check Off Items)

    • 20. CRUD - Delete (Delete Items)

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this course, we will help students with a decent understanding of programming fundamentals create their first big app with Xcode and Swift. If you do not understand computer science basics such as variables, functions, and classes, this course is not for you. It helps if students are not complete strangers of Xcode and Swift because we will be going through big topics such as Core Data and Interface Builder pretty quickly. This course utilizes a teach-by-doing approach. We don't spend much time explaining each topic to death; we learn about the tool or skill by using it to create our app.


Meet Your Teacher

Teacher Profile Image

Joshua Bowen


Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Introduction: welcome to the beginner Intermediate Iowa's development course. In this course, we will learn swift programming fundamentals and how to use X code. By creating our first full fledged up, we will learn about important topics, and I was development, including core data, auto layout and more. This course is targeted towards students with a good understanding of programming fundamentals. Familiarity with the very basics of the swift language will be helpful, but you don't need it necessarily. You will leave this course of the fully functioning to do list app. Let's get started. 2. What we will be building: So this is what will be making in the course. It's It's a do list up. You can go down here, press this button and I had new items to the list food. Just I I'm just adding some random ties on. And then you can also press on the task to complete it and you can slide left to delete the tasks. And all this is armed, stored locally on the user's, and all of this is stored locally on the user's device. So if I exit and close out that and then go back in, um, the tasks are still sword and they're not deleted, so this is gonna be a pretty fun up to make, and you guys will learn a lot. 3. Download Xcode: Hey, guys. And this. Listen, I'm gonna show you how to download X code, so the first thing I'm gonna do is go up here to the the magnifying glass and just typing absolute or just somehow get onto the APP store. So now you're gonna go to search and just type in X code, and this should be the first thing that pops up. So this is the one that you're going you're gonna want to download. So mind just says opening, cause I already have it downloaded. But you should say get so this is X code. It has 3.3 stars. Not that good, but so we have so 4. Create a New Project: Okay, guys. So the first thing we're gonna want to do is open X code. Now we're gonna go create a new Exco project right here. We're going to say single view application for the product name you can put any name you want. I'm just gonna put to doapp for team. Don't worry about that so much right now. Organization name. You could just put your first and last name. Or you can put your company's name organization identify. Um, what the organization identify it does is it tells apple it basically just helps apple identify APS. So most people use a reverse domain structure for this organization. Identify which is like, let's say, google dot com would be com dot google for for that as an example. So you could just put your you could just put calm and then your name or your company's name for language. We're gonna use Swift, and we're gonna want to make sure use core data is on press next. Now, you just save it wherever you want. I'm going to say to my desktop, and here's our project 5. Walkthrough of Xcode Development Environment: Okay, guys. So in this lesson, we're gonna be taking a virtual tour of X code. I'm just going to show you guys some important stuff. So first, we're gonna go to the main story board file, so we call this year, we call it interface builder. I'm gonna be talking about this more next section, but basically interference boaters. Where we create this screens that the user is going to see now you control it are swift. This is we're gonna do most of the actual coating. This is our core data file where we're going toe, it's gonna help us save data on the user's device. This is the assets border. This is where we save all of our images. I'm gonna actually drop in the images that that will be using in the course. You could just get these from from the course page. Just gonna drop the many your dragon drop. So now I'm just going to show you guys some little navigation things. First we have opening and closing panels. You're gonna want to come up to the top right in. Just close the panels, the little turn, grey, and then you press it again. it'll turn blue to open it. We also have to putting two windows side by side. We're just gonna want to come over to this one in the top, right? And then just pressed the two circles. Um, and you can switch which windows are like, side by side. So right now have the main story board and the view controller side by side. If you press option and then click on the file, it will put it on the right side. I'm going to switch it back toe one screen. Now we're going to run the app just to make sure it's working. We're just going to go over here to the run button at the top left before we run it. I'm just going to show you guys over here we can choose, um, the device that we want to run it on everything from ipads to all the versions of the iPhone. You get to choose which one you want to run it on. I'm gonna just running on an iPhone eight plus pressed the wrong button. It should say build succeeded. It's gonna take a little while of the first time you tried to run it so don't worry about that, and here it is just a blank screen. Right now, we haven't added anything, but now we know it's working and everything succeeded, so that's a good sign. 6. What is Interface Builder?: in this lesson. We're gonna be talking about interface builder. If you guys remember from last lesson, this is a screenshot of what interface boater looks like. So what is interface boated? Interface? Boater editor with an ex code Makes it simple to design a full user interface without writing any code. Simply drag and drop windows, buttons, text fields and other objects onto the design canvas to create a functioning user interface . So what that basically means is interface border allows us to create all the the user interfaces that the user is going to be interacting with without actually hard coating them . Would like, you know, uh, code in swift. So let's take a look out how we use interface boater. Okay, so now we're in interface boater. First, I'm just gonna change the device that we're using. I'm gonna change it to the iPhone eight just because I prefer using, like, not the iPhone time. Just a little weird looking to me. Um, So now I'm gonna add in a search bar. So what I what I would do to get and to get an ad like an item into the interface is I just come over here to this button right here. And I'm gonna type in the name of the item. So I'm just looking for a search bar. So I'm just gonna take this, and you just you just click on it and it will go into the into the screen, and you just place it wherever you want. I'm sure in place at this hot. And if I have it selected, I can come over here to this right panel, and I can change certain properties about it. For example, placeholder could make the placeholder search. And so now you know, the placeholder text is going to say search. Um, you can change a lot of stuff. You can change the background color. You can change the bar tent color. Um, you can change the style. So it gives you a lot of freedom to, like, change the to change the items to make them look. However you want, you can change the size. Um, hi. With stuff, all types of stuff. Next lesson, we're gonna be creating the screen for our app and interface boated 7. Create the Main Page in Interface Builder: Okay, guys. So in this lesson, we're gonna be making the user interface for our to do out. The first thing you wanted you're gonna want to do is go up to the library and typing label to get a label. The label displays one or more lines of read only text. We're just gonna come in place in the middle. You can use the guidelines to make sure it goes into the middle, and then I'm just gonna write check in all caps because that's what I'm calling my. And then I'm just gonna change some of the formatting. So I'm gonna change it to size 26 5 and I'm gonna make the style too bold, and then just make sure it goes back into the middle. This is gonna be kind of like our title. Now we're gonna add in a table of you. The table view is a view that presents data in rows arranged in a single column, and we're gonna be using it for toe like hold all of our to do tasks stuff capsule. So just drag one in. I'm gonna make it about this big, and then I'm gonna make it go almost to the ends of the screen. Actually, I'm just gonna put on the end of the screen so you could just make it like that, go all the way to the end screen. And now I'm going to set the delegate in the data source as the view controller by by right clicking. And then it would appear press status sores, press delegate, and I'll talk about what that does later. And lastly, I'm gonna set the separator to none, which is gonna just make sure there's no lines in between the to do items. Now I'm gonna add in a table of yourself. So just table view, and then just grab a cell, drag it onto the table view, and this is gonna be our prototype self for our table of you. So all the cells are gonna be, um, are gonna be based on this one. They're all gonna look pretty much the same based on this custom designed so that I'm making right now. So I'm gonna take the prototype. So I'm going out of labeling. Put that on the left side and I'm also gonna add a image you put on the right side. The image view does exactly what you would expect that holds an image. So and then I'm gonna make it change the size of it about I'm gonna actually make it 70 by 70. Actually, I'm sorry. Never mind. I'm gonna make it 50 by 50. Actually, no, I'm gonna make it 40 by 40. I'm sorry, I keep changing, but like when you're designing APS, you're gonna have to be, you know, changing and seeing what looks good. So this is a good lesson for you guys. Now, we're gonna set the re use identify for this prototype. So which basically allows us to create duplicate table view cells that look exactly like this one. So it just kind of helps. It helps us identify this particular cell so we can make ones that look like it. So I was gonna call it custom. So last but not least, we're gonna adding a button at the bottom. This button is gonna be used, Teoh to create new table of your items. I'm gonna make it 70 by 70 and then just use the guidelines to make it fit to the bottom. Right? And then now I'm going to get rid of the text. So no text and I'm going to change the background color to black. Okay, so now I'm gonna put a image on the button so that it has a it's gonna have an image on. I'm going to use the white plus image if it resize it itself. All you have to do is just go back and change the size again. I don't know. Why does this just change it back to 70 70 and then put it back into the correct position? And there you go. Now you have a button on the on the I mean, now we have an image on the button so that the user knows kind of what it does just by looking at it. So this is our completed design. It's gonna look nicer when we run it. Next video. We're gonna talk about auto layout 8. Add Auto Layout: Hey, guys. So in this lesson, we're gonna be talking about auto layout. What is auto layout? Auto layout dynamically calculates the size and position of all the views and your view hierarchy based on constraints placed on those views. So what that basically means is auto layout. Basically, make sure the U I of your screen is proportionate on any screen size, and it will look good. And it will look the same on its tiny iPhone four or a huge iPhone eight plus. So this is an example of what the screen looks like without auto Leia and with auto layout on the right. On the right is with Auto Leia and on the left is without a Leo. So just go into your main storyboard and we're gonna start our start adding auto layouts, our view. So the first thing we're gonna Adauto layout to is this check button. We're going to go to the Chek Bun and then we're gonna go down here to this. Um, did like this button with two boxes on it, and then we're gonna press horizontally and container that's gonna align this label horizontally in the container toe to be in the center. Now we're gonna right click on the check button or the check. I'm sorry, the check label and drag it onto the table of you and just let go and then just press vertical spacing. What that's going to do is it's gonna say a constraint on between the label and the table of you. So it'll be the same distance away from each other on every screen sides. So now you're just gonna come over here into the right panel and you're gonna change the distance of this 2 30 So that means that on every screen size, it's gonna be 30 away from the table. Lastly, for the check label, we're going to align the top to the safe area. So just select the label again and then right click and just drag anywhere on the screen. So you see the screen until you see the view turns blue, and then you just gonna impress toss basis, safe area and change the top space to, um, 16. So now all the auto layout is added to the view. I mean, I'm sorry all the auto layer is added to the Czech label. Now we're going to start adding it to this table view. So first, we're gonna align its center just like we did the label horizontally in container that's gonna center in the containment. Now we're going to add the bottom space to the add button, So just right, click the table of you scroll and select the the button and then just pressed vertical spacing. Now we're gonna come down to this area where we can see all of our constraints. We're gonna find the bomb space to button, and we're gonna edit it to be 22. Okay, so this isn't an auto layout thing, but this is just something that I wanted us to add. We're gonna go to separator and set and change it to custom. Then we're gonna set the left zero what that's going to do. It's just going to get rid of the, um, kind of tabbing that X code automatically adds to table views. That kind of doesn't look that good. Now we're going to come to this bun, our new constraints, and we're just gonna check this and check this. What that's gonna do is it's gonna, um it's gonna pin the table view to the left and right edges of the screen. Now we're gonna Adauto layout to this, but not the bottom. We're gonna set constraints for the width and height to be 70. So just press check check here. So the So the button will always be 70 by 17. Now we're going to right click the button and drag it onto the view so that the entire thing is selected and we're gonna set trailing states, trailing space a safe area. Now, let's go to the ruler, go down to our constraints right here, and change this to 20. Now we're going to select the button again. Right? Click drag to the whole view, selected and bottoms basis, safe area. And we're gonna change the bottom space to 17. So now we're not getting any heirs anymore. As you can see, there's no there's no red meaning that all these all the three components are fully completed with auto layout. The last thing we're gonna Adauto layout to is this prototype. So So what we're gonna do is we're going to set the label to have a center. Why not X with a center? Why? So it will be aligned vertically in the container, not horizontally. And then we're gonna come over here. We're gonna add a leading space to container. We're gonna do the same thing with the image you vertically in container sensor vertically in the container. And then we're gonna add a, um, trailing space, trailing spaces of the space of the right and leading space is the space that left. Lastly, we're gonna constrain the within the heights, always be 40. And that should be it for our auto layout. So now the screen is gonna look the same on any device size, and it's always gonna be perfectly proportional for every for every user's phone. 9. Create Custom Table View Cells: Okay, guys. So in this lesson, we're gonna be creating the table of you sell class for our custom table of yourselves, which are these? If you don't remember, So the first thing we're gonna do is go to file and then choose new and then choose file and then Coco touch class next. And then just it should have you on tape of you sell. If you don't see it, just press this blue thing, um, and find in this list, and then we're just gonna call it, um, custom so and then just for us. Create And it should. So it should show up over here. So now we're gonna go to our main story board. We're going to select the prototype, so we're going to go toe custom class, and then we're gonna type in the name of the class that we just created. Now we're going to double screen, close this window, and then I'm going to press option and impressed on the custom self out. Open it on the right side, then I'm going to, so I'm going to select the label. So I'm going to right click the label and drag it into this custom so class. And I'm just going to give it a name. I'll just call it, um, name, and then I'm going to do the same for the image. You just right click and drag, and I'm gonna call it, um, image. Hold it. So now we can reference these two items and affect them in our code using these variables. Lastly, I'm gonna add a completed property. Something is high. Var completed, Dr Dybul, and we're going to use a exploration points of force. Unwrapped the optional. Lastly, I'm gonna make a new method called layout sub views. This method is part of the Swift library, and I'm gonna use it to make changes to the table views layout. 10. Connect IB Outlets & IB Actions to the VC: Hey, guys. So this is gonna be a pretty short lesson. All we're gonna do is connect up the I B outlets and actions from our screen onto the view controller so we can use them and reference them in our code. So the first thing we're gonna do is open up to screen. So pressed this two circles one, you should have the U controller on the right, so go to option and then selective You controller file on the left and it should open up the view controller. I'm just going to get rid of this comment. You don't need the comments. And then now I'm going to press on the check label and then right click and drag it into the view controller. And I'm just going to give it the name. Sure label. I'm gonna take the table view selected right click drag into the view controller. I'm just going to call it item cable. Lastly, I'm gonna take the button, Select right click drag on. But I'm also going to select the button again, right, click and drag. But this time I'm going to make it an action. So it should say action up here there was going to say add you, I don't That's gonna be the name of the function. So every time that I press this button, this function is going to get run. Lastly for this lesson, all we're gonna do is at a corner radius to the button. So I'm just gonna say add, but him dot corner radius no one dot lair dark corner radius equals 35. So, as you can see, I'm referencing add button, which is this You just made the reference in our code, and I'm going to get the admin, get its layer and then get the corner radius property of the of its layer and said It's a 35. So that's basically just gonna make this square into a circle when we when we run age to be a circle. So that's it's a really short lesson. Next lesson. We're going to start working with our table view and showing items on the table 11. Display Items in the Table View: Hey, guys, welcome back. So in this lesson, we're just going to set up our table view, set up the functions and tested with some test data. So the first thing we're gonna do is create a test array of strings just to see how the table of you looks with, like, some some stuff. And so I'm going to say, Let test items equal. Um, you can put anything you want here. I'm gonna say yes. Shop queen, sleep. I'm just putting random tasks. And since this is a to do list So this is my array of test items. Now I'm going to add the you I table view data source and you I table view delegate functions to the view controller. Earlier, we set the table of use delegate and data source property to be the view controller. So I'm gonna explain what that basically means It basically, we're basically telling swift that we want this view controller to control the the data that shows up in the table view and also, um, the properties around that data. So basically, the view controller just controls everything to do with the table of you. So you should get this air saying type you comptroller does not conform to protocol. You are a table of you daughter source. Do you want to add protocol? Stubbs? You just press fix. And it should pop up with these two methods on these air. Just like these are just required methods that you need If you're gonna have a table view in year, um, you control it, so I'm just gonna cut and paste them down here. So for the number of rows and section, I'm just going to return test items dot count. So that's basically saying that we want there to be four cells in our table of you, just like there are four cells are just like there are four items in our around. So for row, at this function, we're going We're just gonna right looks so cool. Item table. Uh, de que reusable. So without identifier Customs cell, which is the name that we gave to our custom Selves as customs. So which is the name of the table view? So, class, I'm going to say sell dot name got text. If you guys remember, name is the name of the label that is in the custom Selves. That's what I'm saying. Celadon name dot Tax equals test items for index path row. So basically, that's saying that we want the text for each sell of the table of you to be the corresponding item in all right, And the last thing going to just say returned. So we're gonna add one more function called. Yes. I've been high for road. That should show up. This is just going to say how how tall you want our take of yourselves to be. You said it to 50. So you want each of ourselves to be 50 tall, and that should be everything we need. So I'm just gonna go ahead and run it. And here's all of our items and they're showing up in our table view and everything looks great. So good job, everyone 12. Create a New Item: Hey, guys, in this lesson, we're going to be adding functionality for the user to add new items of It's a delis. So the first thing we're gonna do is create a you are text field. So just go into your add new item method and type. Let new item field. He will new I text field and close brackets. The U. N. Text field is a box that users can write in or put in putting. Now we're going to create a U I. Alert controller. You Wyler controller is a sub view that pops up on the screen. You can put buttons, text fields and headings inside them. It's like the view controller, but smaller and not permanent. So I'm gonna say, Let menu equal. You are alert controller. I'm going to give it a title of add new task. I'm going to give it a message of nothing, and then I'm going to give it a preferred style of alert dot alert. Next thing I'm gonna do is add a add the text field that we just created up here to the alert controlling that we just created right here. Many are add text field and then press enter and then just type in here, man, you text you'd and new item field dimples, ganglion texts. So we're basically saying this new item field equals equals the text field in the you are alert Controlling. I was gonna say fix. Now we're going to add some u i alert actions to Are you Isler controller? The U Isler action is a button at the bottom of the U Isler controller. I'm going to say, let's save equals glide alerts Action title save Sile default. Remember to put this dot And then for here I'm just gonna select it and I'm gonna press center. I'm gonna is hype inhuman? Just gonna take action in. And then this is where I'm gonna do the coding. Where's this code? I'm gonna say, if new item field Dark Tex is not equal to blink, meaning if there's text inside the text field, then I'm going to do something. So what I'm gonna do is I'm just gonna say test items dot append new item dot Knew I don't feel dot tax. So I'm basically just a pending. I'll just say fix the problem. Was that the test items? The problem was the test items array I was was what they let I used the let keyword to create it. So which means that it cannot be changed. So I'm just changing its evocative are so that I can change, um, the contents of the ray and then we're gonna add self. Whenever you get an air over here, sometimes it will allow it'll, like, fix it for you. So just read it and you can just have it fix it for you sometimes. Next, I'm going to say self dots item table dot reload data. This was just gonna reload the table view every time that I add a new item to our test that it was a race to that. Whenever there's a new item added, it will just immediately show up in the tape of you. So now we don't the save button. Now we're gonna create the cancel button. Let cancel equal. You are alert action title cancel style default. And then come here. Press enter Action. No one's going to say return to get out of the alert control. No, I'm going to add the alert actions that we just created. Saving. Cancel to our alert controller I'm gonna say menu, add action, save. I know. I'm sorry. Cancel. When you don't add action safe, I'm putting the cancel before the save because I want to cancel to show up on the left, and I want the safe to show up on the right. You'll see what I mean when we run it. And lastly, I'm gonna do is present a menu animated true completion? No. Okay, That should be everything, guys. So if we run it, um, it should pop up with an alert controller that allows us to put text in a text field and then save that text into our test items array right here. So let's run and see what happens. All right, So here's our, uh I'm just gonna press the add button, and this alert controller pops up at new tasks, which is the title we gave it. Here's our text field. And here's our cancel button in our save button Cancers on left to save buttons on the right. So I'm just gonna add a new task. We're just going to say, um, Dr I was gonna press save and it shows up in our table now. I'm going to say Dr and Cancel and nothing happens because cancel just brings it back to the main view. Cancel. If I first saving nothing's there, it won't save anything else. So everything seems to be working. Guys, good job. 13. Check Off Completed Items: a guy. So in this lesson, we're going to make it so that if the user taps on a to do list item, it is gets marks marked as completed. So the first thing we're gonna do is go to our customs so vile and we're gonna comment, making you method, we're going to call it reload. So inside of our reload method, we're going to say, if completed and then we're gonna say else. So the completed that I'm talking about you is this variable that we created up here? It's a boolean. So if completed equals true, we're gonna do this, and if completed equals false, we're gonna do this. I'm using this completed very well just to tell us if the task is marked as completed or not. So if the task isn't is marked as completed, we're going to say self dot layer dot capacity equals 0.3. I was gonna say image holder dot image equals ur image named. Sure. So what I'm basically doing with this line is I'm saying this image view that we have reference appear that is in our table of you said, that's in all of our table view cells. We're going to set the image of that specific table of you. So in the image holder to be this check image, which if you go to your assets, it should be This image right here, if completed, is equal of false. Also known as else we're gonna say self dot layer. The capacity cools one and image holder dot image equals no. Oh, and by the way, if you don't know what opacity is, it's just the transparency level one being completely solid and, you know, no transport, no transparency at all, and 0 to 9 being on different arm spectrums of transparency. So point there is pretty transparent. Now I'm just going to call the reload function that we just created in layout sub views, the layoffs of these method. Like I said in the other lesson, it basically just helps to deal with styling of sub views. So we're using it to deal with the styling of this year. I table so so in our awake from mid function, which is just the function that is called when this, when the custom cell is in Stan Shih ated, we're just going to say completed cools balls I'm gonna go down here and then I'm gonna created you Met that I'm just gonna type in, did select and it should pop up. It's just it's a table of you method. So it's press, enter. And in this method, this method gets called every time that the user taps on a table of you. So So it gets called for the specific. So that was tapped. Someone's going to say, let so equal table view Got so for row at index path. Lower case I as table as custom. So I'm going to say so. So basically, this line just gets the the exact cell that was tapped. And then I admit it. You can just use this variable to reference that exact so and then she'd say so dot completed equals not so dark completed. So this is a bit of interesting line here. This basically just takes the completed property of the customs. So this completed property right here and it says into the opposite of what it was previously said. So if so, what are complete? If Saadat completed was equal to true, this line would make it false, and if so, dot completed was equal to false this line would make salt are completed equal to true. Now I'm going to say so. Don't reload, which is this reload function here? And then I'm gonna say table view dot de select row at lower case I index path and animated equals True. So that's that's basically a guys. It wasn't that much coding. So now I'm just going to save this file, and then I'm gonna just run the entire app and see if everything is working. Okay, So I'm just going to select a cell from this list. I'm just going to say cook. If I select it, it is marked as completed. We get our check image right here, and the opacity is lowered 2.3. And if I select it again, it goes back to how it was. So you could just switch. Then you can select all of them whoever you want. So that's basically it for this lesson, guys, 14. Delete Items from the Table View: guys, welcome back to another video in this video. I'm gonna be showing you how to allow the easier to delete table view items. The first thing I'm gonna do is I'm gonna write trailing swipe action and it should be a table of you function that pops up. So just press enter an issue, pop up with this table of you function, and then you're just gonna put inside the function you're gonna put Let delete equal delete action. Kratz Index packed. You're probably given Just have type this out. It's not gonna complete it for you, do I Swipe actually in configuration and the reason it's not completing it for you is because we're the function. We have not created it yet. So now we're gonna go ahead and do that. We're gonna say function lead action at indexed power in their spy. You like intellectual action. What action In cool You are contextual action styles destructive because whenever you're doing a delete type thing, you're gonna want to use the destructive style. If it's if it's an option title, just gonna sing toe and handlers Just gonna you're just gonna hover over its that no hover over you're just going to select it so that it's blue and then just press enter or return for action? Are you just gonna put action? You completion and then here, just going to say itself. So test items that removed don't index pot don't through sitting. No, I'm sorry. Put it to you. Action dot Image close. You are named, actually. Bulls homer dot Red man returned option. And that's basically everything you have to do for this toe run. So I'm just gonna run it and see if everything is working. Okay, So here's our table view our list. I'm going to slide left, and you should see the delete. So this press delete. Okay, so now our delete action is working, and everything seems to be working fine. So not to 15. What is Core Data?: Hey, guys, in this lesson, I'm gonna be introducing you to core data. What is core data? You use core data to save your applications. Permanent data for offline use to cash temporary data and to add undo functionality to your app on a single device. So what does that all mean? We're not really gonna talk about what all of that means, But in this, we're just gonna focus on saving your applications Permanent data for offline use. So what core data basically does is the stores data locally. That means that the data is stored directly to your individual device and only you have access to it. It doesn't use the Internet or the cloud or anything. So it's it's literally stored on your device on Lee. So that's basically what cord out it does. Um, next lesson. We're gonna set up a team core data 16. Create the Item Entity: Okay, guys. So we're going to get started with core data. So what I want you to do is go to day to doapp don xy data model d file. Just press on that, and you should see a screen that looks like this. So we're gonna be creating a new entity. An entity is kind of like an object. Um, it has properties, so I kind of look at it like, almost like a class. So let's create it. So let's say we're gonna go down here to add entity, and we're just gonna impress it, and it should create this new entity blank entity right here. We're going to press on entity, and, um, hold down on it is that it allows us to change the name, and we're just gonna call it, um, the task council is on task. So now we're gonna go over two attributes, and we're going to add some after attributes. We're going to have a name, attributes of type string, and we're going to go over here and we're going to press this and we're going to un select optional because, um, this is a mandatory property, and we're also going to have a completed property of type Boolean, so it's either completed or it's not completed. And we're also going to set this to mandatory. So unchecked, optional and these are the only two properties we're gonna need. So our entity, our task entity, is basically done, so that wasn't so bad. 17. CRUD - Read (Show List of Items): Hey, guys. And this lesson, we're going to switch the array that our table view is reading from two to an array of core data task objects. If you don't remember from last lesson, the task is the entity that we created. It has a name and a completed property. So it's basically just like to do is tasks. The first thing you can do is come up here se import core Donna. So now we can use all of the core data stuff now that we've imported it. So we're going to say, let context equal you I up location don't shared dot delegates as, uh, delegates persistent container dot you contexts. So this crazy line right here basically just gets us the context, which is basically just something that we have to do to use core data. Um, you don't really have to understand why, but just know that yeah, we have to have this context in order to use court outta, and we'll be using this context variable later, too. Get cord out of objects. So there it is. Now we're going to say bar items, people's an array of tasks. So this is gonna replace our test items as the array that our table view looks to for data . Okay, we're getting a use of unresolved identifying task. This should go away when we run it. Because, as you can see, we did create our task entity right here. So, um, X code is probably just hasn't caught up yet, so it just doesn't know that it exists. But when we when we run it should this should go. Now, we're going to come down here to the number of rows and section table view function, and we're going to change be returned. Two items not count. Because now we're looking to this items or a and we're no longer looking at this test items , right. In order to fetch the items from core data, we have to use a fetch request. So we're just going to create a variable called request of type N s fetch requests and make it fetch tasks. Then we're going to set our items array to the contact stop Feterik lists, and we used to do catch block because, um, swift syntax makes it mandatory. Since this is an air prone activity and you can get rid of this air by just pressing fix to force unwrap the optional and last thing we're gonna do is go into ourself, a row at function, the table of you method and we're going to and we're going to change the Saudi unnamed, not text to equal the items in next. Pack that road name and then So we basically just made it Look at the core data items or a to get its its data and get the name property from whatever task entity is looking at. And then we're gonna say so dot completed people's items in next path the road dot completed. So now that we've added this completed property to the self a row at function, whenever the APP loads up from the beginning, the tasks will immediately be either completed or not completed based on what was saved for the task that that for the test that is at that in next pack. So I'm going to just say control or I'm just gonna say command be to build And it said build succeeded. So as you can see where the air is gone, because ex coaches was being a little slow with realizing that, um, this core data entity, Israel. So now that it has built and it knows that it's really, um this should be all good. We're just gonna run it and make sure, Okay, so we don't get any airs. So that means that everything worked. And next lesson, we're going to continue with updating our application with core data. 18. CRUD - Create (Add Items): Hey, guys. So in this lesson, we're going to be, um, updating the ad item functions so that it uses core data. So the first thing we're gonna do is create the ad function. I say, let task us all text. That's what I context comes in, has dot rules. Well, se my name's this. So So what we basically did in this ad function that I just made is we created a new task, and you cord out a task with very well named task. We set the name to be the name in the parameters. Then we said the completed to automatically be false because it was just created. So how happened it already completed? Um, and then we saved that We haven't created this say function yet, so this air should be there. And and then we added the task to our items array so that it will show up in in the table view. And then we reloaded the table data. I don't know why this airs. Oh, I'm sorry, guys. So change this to self dot item table and this should be item table because I forgot that I had I named the variable for a table view item table, so it should match whatever you call the today knowledge create this, say functions something. You're in this area. You say function, save the man, you say do touch. And I'm using a do catch block because core data stuff is the data stuff requires do catch blocks because because sometimes they can have heirs. So the do catch block is just like a mandatory, um, safety measures about if the code fails, there's that safety measure there. I'm not really gonna add anything anything to the cash box, because this should always be true for our purposes. But in the future, you're gonna have to ask you to the cash box so that if there isn't area, the catch block will handle whatever the air is. But basically, what I'm doing in here is I'm saying I'm telling the context to save its current state because I just added it in your item here. So I'm basically just saying saved a new item to core data so that when I closed that and open it again with the new item that I just created will still be there. So that's why I'm doing not That's why you need to save stuff in Cordoba and to save something core data. It's just simply context sausage. So now I'm going to go up to our add new item function, and I'm just gonna change the way that we add items. So in in this if block, I'm just going to move these lines and just switch it to be so, uh, you item feel dot tuts exclamation point. So that the optional his press. So what this line does is it goes and it uses the ad function, and it gives it the parameter that it wants to save. And this ad function is called. It saves accord outta. There you go. That's simple. 19. CRUD - Update (Check Off Items): Hey, guys. And this lesson, we're going to be learning how to update the information about the task about our task objects in core data. So this is gonna be very simple. We're just gonna change a few lines in our did select road table view method, and we and we should be done. So the first thing we're gonna do is go to that method. This method right here did select row at in Next Path. Now you're going to make a task variable. So we're going to say we're going to go under less so equal table view. Not so far. Oh, we're just going to say let I always have capsule. I say let task equal items index path dot robe. So remember, items is our array of core data task items. So that's why we're going to this array. And we're just getting the task at the current, um, at the selected index path. So now we're going to say task dots completed equals, not task doc completed. So this is basically just the same thing as this cell dot completed line that we did earlier. The only difference is the task line is actually changing the information in core data, whereas the celadon completed is just affecting the table view at that specific run time. So once you close out of the app, all the information is going to be gone, whereas now the information is gonna be saved. So the last thing we're gonna do is just call our save method, which is this method right here just saves the context. Um, and make sure that you know everything in core data is saves or the all the changes. Sick or not, I have been saved using the manage context. So that's really a guys, um, if you run it. So let's just create a new task item. Let's say I fold the laundry. So now if I select it, it gets saved us completed. And if I close out of my up and go back into the up, it stays as completed. So now it seemed 20. CRUD - Delete (Delete Items): you guys and this lesson, we're going to be changing our delete functionality to also use core data. So this is gonna be the last step in our crowd. Create, Read, update. Delete. Um, change. So after this, our application should be completely converted. Score data and everything should be saved locally on the user's device. So this is gonna be another pretty simple lesson to finish us off. So all we're gonna do is go to the delete action method right here, functionally action, and we're going to So we're just going to say self dark context dot delete itself items index path row. So all this line is doing is just going to the context, um, the manage context and deleting the item from and deleting the item at that in next path from our core data managed context. What we're gonna say, self dot save, which is just this function right here. And remember, we have to use this self in front of it. Since we're inside of this, you are contextual action object, and then last we're gonna say self items, not remove index path that room. So this line just handles the, um the items already. That's just kind of important for a table view, so that's not really anything to do with cord out. And that's just our table view stuff we're gonna is elite this test items line because we are using the items right now, and that's basically that's all we had to change, and everything should be completely saved now. So now if I delete this and then close out my up and go back in, it's empty because, um, we're using coordinated and everything is permanently saved on the device. So the action that I deleted before I close the APP is still going after after I close it, so that's it.