What's up everyone.
Heartbreaker that slopes dot com let's just dive right in in the last video we got segues working and
we got our unwind Segway working super easy to switch back and forth between screens like super super
easy no code even required which is really cool.
And in this video we want to get our view controllers finished being set up but we don't actually have
code for them and things like that and we get some other weird things going on that we want to fix.
Refactoring some names and stuff.
Ocelots do all that stuff.
But first things first I'm going to go ahead and get status to see what's changed.
I have some changes add Desch a good commit Dasch am and we're going to say segues and unwind and just
checking my branch get checked out.
OK so that was less than five.
So it's let's actually it's actually push this up first so get committed so get push Orjan.
Lesson 0 5.
Wonderful.
And just to be sure I don't think I push my lesson for branchial get check out lesson 0 4.
If you're if you're wondering Mark why are you showing us this stuff.
Well I found that if I don't show you the professional things that we do on a regular basis when you
actually go to encounter at a job you're IT guy who's interviewing you or you or your brand new boss
is like wait a minute why didn't you ever learn get.
That is so important and you're like well I just took this course.
They did teach me well if you're taking a course.
Of course we're going to teach you and so I leave the stuff in.
OK get push origin.
When you say lesson 0 4
and here's something interesting so maybe you're thinking won't mark now.
Now you can check out lesson 0 6 right.
OK.
We were on lesson five and let's just check out six What we don't want to do that because we would be
creating a code from the lesson for Branch and it would be outdated.
So we actually need to first do is get check out lessoned 05.
Oops what did I do here.
We pushed.
That's fine.
Weird stash.
It's just something changed on it.
Just by nature having the file open which is fine.
So get check out lesson 0 5 so check out that first.
And now we'll create the new branch you get.
Check out Desch be less than this 0 6.
OK.
So a little bit of get magic you're going to see a lot of this.
And another question I get a lot when teaching these lessons is Mark why are you using the standard
terminal.
Don't you know there's all kinds of cool tools in hackery and stuff you can do.
You can sure get branch right from the terminal and you can have pretty colors and do hockeys and all
this stuff.
Well I don't do any of that stuff because I got to teach it and you guys won't have that stuff.
And secondly I actually don't even use those things in my own development.
I just like keeping everything based and clean.
And maybe that's the Teach for me but I just like things beyond being pure and clean.
It's weird but that's why so commander made it clear all this mess up we are on Branch the proper branch
now and we got her three new controllers in here which is great.
The Segway is in place.
And so what I want to do is I want to rename this view controller and I want to set up some folders
here.
We probably should have called this view instead of views and I would create a couple of more groups
here.
So a new group we're going to call this controller and a new group called model for model view controller.
OK and I like to put all the files where they need to be.
So model.
OK.
And this controller file we should move into the controller folder.
So you controllers going and controller and this name is really bad.
It's not descriptive.
OK.
Everything you do in coding should be very descriptive.
You know I've worked with programmers who just like make the most obscure names and they take all the
spaces out and literally where do you have no idea what's going on.
Why do you think Apple always has like super long function names like one from Segway.
It's because they want you to understand it doesn't matter how long it is.
So let's go to our view controller Scott Swift.
And let's rename it so double click the name after class.
OK that's our custom name.
Right click it and go to rename.
All right.
This is a really cool new thing in x 9.
It could it'll refactor everything for you.
So what we're going to do is we notice how even in the storyboard it's reference it's going to rename
that so we don't have to reconnect anything.
So that is just awesome.
So what we're going to do is we're going to call this what is this welcome screen so welcome.
VC I always put VC at the end.
Apple likes to put the whole world view controller.
That's kind of pointless.
VC I know it's a view controller and it's shorter but I do put VC on there because you do want to know
that it's a controller file and not like a button file view or a model file so just press enter.
And it's now refactored it as it should be.
Which is great.
OK.
So there are welcome VC and the next thing I want to do is create two more of your controllers.
OK one for each of our of our view controllers here.
So right now just by having these in Interface Builder what's happening under the hood is Apple on iOS
is creating a view controller with code like default implementation code so if we look at our view controller
here OK what it's doing is basically that you have you control.
It's implementing just an empty blank one.
So no custom code and it wouldn't have any of this stuff and it just boilerplate stuff that's happening
underneath the hood because your views here actually can't run without code.
So you may think there's you may think there's no code but there actually is code going on under the
hood.
Apple's just doing that for us automatically and that's not useful to us because we can't actually connect
to buttons and things like that.
So we need a view controller for both of these.
OK so for the league VC and the skill of VC.
So in the controller folder we're going to go to New File Coco touch class because we need blanks with
Farben an actual cocoa touch or why Kit class for for iOS you view control is what we want in the subclass
to make sure it says that there and let's call this one league visi.
We don't we do not want to also create a zip file.
This would create an extra interface file for this view controller we already have one here in our interface
builder.
So click next and create.
All right and let's create a second one.
So new file would touch class and we're going to call this one skill Visi and again make sure you have
your controller is the subclass.
OK so now we have these extra two view controllers.
But now we need to connect them in our storyboard and that's fairly simple as well.
So remember right now because we just drag these an interface builder when the app goes at runtime it's
creating a standard view controller with none of our custom code in it.
We want to change that.
So all you have to do is over here on the left hand side in the document outline select the view control
that you want which is this one here and this is our league controller.
And then on the right hand side over here there's a little icon here called the identity inspector.
Click that and see all the classes you have your controller.
All you have to do is change this to your league.
And the important thing to know is you can't put anything in here.
It has to be code that inherits from you have you control this colon here.
And the word you gave you control or after means your custom class your custom view control is inheriting
from the base view controller.
If it doesn't this would not work.
It would not have let us pick this.
That's a very important thing to understand.
OK.
And let's click on the next controller on the right hand side over here.
It's highlighted over here.
Identity inspector and let's change this one to the skill of the see.
OK.
So these are now connected.
They're now connected to the code.
So when I say we select this one right here and we click the assistant editor it's automatically going
to pull open the league Vinci Code so we can create Iby actions and things like that.
OK.
So we've now got our our code cleaned up what we've done is we've created some folders here controller
we've connected them to the store.
And this is how you do your apps whenever you're dragging interface a file or view controller files
and the interface builder.
You have to go and create the controller code for it and a lot of new people forget that they build
all that interface like well I can't find that code for it because you didn't create the code for it.
And you also one more one more rookie mistake though a lot of people make is they will go into the view
controller and they'll create a new Swift file like this.
OK.
And the call this you know my Visi and it's empty and they're like what's going on over I should probably
create a class and we'll call this you know my Visi and let's inherit from you I view controller and
you're thinking oh this is great.
All right.
But use of undeclared type you have your controller.
What's going on.
It's why is it not working.
I don't know.
This happens all the time.
I see people give me questions on this all the time.
Well the problem is when you create a swift file it's importing Foundation which is just the code for
swift.
It does not have cocoa touch all the frameworks that Apple has built for iOS development does not exist.
So in order for this to work you have to import UI kit like so you buy kit includes the foundation which
has swift code in it but also it includes all of the Iowa stuff like you have View Controller and that's
a problem that a lot of people make.
So don't do that or make sure you do it there.
So a lot of good stuff here.
We're going to call this video down a little bit short but it's important for you to digest what just
happened here.
And let's go ahead and move forward into the next video.