Categories in Objective-C - Objective-C Tutorial

161 Просмотры
Издатель
Categories in Objective-C is a free tutorial by Mark Wahlbeck from Objective-C course
Link to this course(Special Discount):
https://www.udemy.com/course/objectivec/?ranMID=39197&ranEAID=Gw%2FETjJoU9M&ranSiteID=Gw_ETjJoU9M-ufJw_poa65Gq0NdEueRvMQ&utm_source=aff-campaign&LSNPUBID=Gw%2FETjJoU9M&utm_medium=udemyads
This is the best Objective-C Course
Course summary:
Write code in Objective-C
Convert Swift iOS Apps into Objective-C
Convert Objective-C iOS Apps into Swift
Build Simple Node & Express Servers and APIs
Communicate between iOS apps and Servers
English [Auto]
Here we go again. It's going to be so much fun writing some code. Ex-coach open it up. Now by the way if you didn't know this is Mark Preston of soap's dot com you like yeah I heard it the last thousand times. Well now you know so here to talk today about categories object to see category's K.. We're going to create it basically a category is just an extension of a class. OK. I actually use these quite a bit on my professional projects. For instance one category I use all the time is an extension to N.S. date. I'm not happy with all the data. Well they have data formatting tools but it doesn't always give me or I need because I like to use one type of format usually it's ISO date format I use and on the back in the front end and so I want to do all these tools that you know the month the years and it just formats that free up exactly as you need. And as you start working with it you're can understand how it's a pain working with dates. So I created this category. Basically it's an extension in his day and all I have to do is include it my project and it adds extra features to the state class so I can use it right on my and my project. So let's go ahead and clear out that new file. It's really easy. So first we're in a credit class let's call this let's call this Honda because it's going to be a Honda. All right. And also this Honda has some properties on its strong and as string. This one is probably the model right at property atomic. Strong will say any number call this Miles. OK. Probably has a function too or multiple functions right. So void. Maybe we want to increase the miles so increase Miles you know to odometer this plane around to Odon it or another one that's probably like Dr. Wright has We've got some some generic function here and some properties Let's go ahead implement these functions like so personally blank for now. OK. So the idea is you have a class right and it has core functionality. OK here's here's. Here's our core functionality for a class. Can you get a nice hand there right off the lot. It's pretty brand new car. You know that you bet. This is a Honda. That's a good relie old reliable car. But then all of a sudden you know sloppy joe gangster guy with his hat to the side you know in his baggy pants skinny white guy right. He's like you know what I want to souped up my Honda. You know so he's like yeah let's create a category for that. And so he's like all right. So let's go ahead and create a category. And I believe we select Objective C file here and you click next and instead of empty file you're going to pick a category by the way. Extension is very similar to category. We're not going to cover it but basically an extension is just like a category an extension to a class except you can only use on your own classes whereas a category you can use on other people's compiled source code to extend the functionality and features. OK. So this category is going to be called souped up. If that's how you spell souped up pay and file type category grade class we want it to be of class Honda Okay category of Honda. So you know you're never that old school offspring songs like pretty fly for a white guy like whenever I see those guys in those harness that's what I think about like you know any white guys who like think they're cool with those souped up Hondas. Anyway so cool sloppy joe gangster that's his gangster name by the way. He's I want a super. My Honda. So what does he do. He does some really stupid stuff. OK. This is what he does. OK. Ad ugly spoiler he adds a function here called an ugly spoiler. OK then he has something else in his category. He can do what he wants. OK add up the spoiler. He also wants to add gold plastic spinner rims. OK. That's cool. OK. And so yeah. And then for some reason. OK. He wants to scrape off half the paint right. Why is it with friggin Hondas and these souped up Hondas like half the car all the paint scraped off like you're showing that you're doing something. Oh. And lastly there is another function we want to add. You know called Ad horrible sounding muffler cap. You know what it is. So this category is adding features to the Honda car. OK. And this could have been a string of course as well too that we're adding that we're adding a category two. And of course you can add properties as well too. So you know we could add a prope
Категория
Разработка на iOS Язык программирования Objective-C
Комментариев нет.