So work come back again this is probably the lesson you have been waiting for.
How to use faith in us.
I'm not going to talk.
I'm just going to jump into school.
They showed you how to use it.
And when I go to execute the command shift and file our I was single view application I'm going to call
it my swift virus app and the only thing I want to make sure I change is the language should be left
out Swift.
So with the language shift I'm going to say next I'm going to place it somewhere eventually.
I mean here the big difference that jumps out is this.
We don't have a dot H and a dot and file anymore.
Everything is inside of one file called View Controller at Swift.
So if in the past you avoid the body of your controller that age you can't alter that and make that
a storyboard.
Now you only worry about view Concordat Swift and the main storyboard so everything is in one place
inside our view controller.
Right now I'm going to get rid of all the comments and some things should begin looking familiar to
you.
So we have this thing new controller of the type you view controller the same way we had at interface
View Controller Carlo View Controller.
We have this guy view that lot with superb view that it and the one question you might be asking and
that's a very valid question.
Where do I put my outlets because in the past we used to do all of our the outlet declarations inside
the dot H.
Fine.
So I'm going to get myself a little bit of space in here.
You don't need to worry about these declarations and definitions in a few lessons.
Now when we go to the next section which is more of you know hard core programming I will talk about
object oriented programming and what is a class and what's a superclass and what are the methods which
are the functions of a class.
What are these.
You know you control our life cycles.
Will cover all of these.
But what you need to worry about right now is this right after your class declaration and inside the
body of your class you want to put all of the outlets.
So this is where we put all the outlets.
So let's see how we do that.
I want to go to a storyboard and in my story about I'm going to make two things.
One is and by then as usual and the other one is a label kind of as usual.
And I'm going to change any of their properties here.
I actually want to do all of these properties by programming so not only do you get to see swift We
also get to see some newer stuff as well.
So let's go to assistant editor and yes Destinator I'm going to drag the Padan in here say it is my.
Then I'm going to drive the labeling here say it is my label and I'm going to either I get the button
changed the type into an action and say this is my action.
So whenever it is being touched up inside.
Call this action.
And that's about that.
So diking.
And just like the way we did with the objective see if we are doing it in the street.
So let's go back to our editor and our view controller.
I have two outlets in the past they were being written something like this at profit the non tarmac
which is the default behavior here.
And then I beat out that you are label or you or I but then and then asked to X which we don't have
at all.
In.
We don't need to have pointers for anything.
We will talk about the standards.
Right.
Why it is like that is with under the name of our outlets so my label.
So even though this isn't exactly the same format it has some similarities with what we had in Objective-C
and that's the only thing that matters right now for you to feel that well this kind of is similar to
that until we get a better sense of what they are and how they work and everything.
So to do actually something functioning is what I'm going to do.
I'm going to go to my view with a lot and in my view it the Lord I'm going to say my but then DOD background
color and is telling me you have to give me a new color.
I'm going to say it's you eye color dark dark gray.
And then I'm going to say my body in the title color and title colors or titles have to be set for a
certain state.
Some say set title color who you are a color that too white for you.
I control the state DOT Norman and I'm also going to say my part in Dardis said Titel.
Where is that title.
Another tribute the title title.
I'm going to set title to hits me for you or I control the state DOT Norman.
So as you can imagine this is a method that you're calling from you I Baden's in this case but then
it takes into work humans and it does something it sets up something on our button.
So if you run this now we should be able to see our But then with the dark background of white text
color and a title on it that says hits me.
Let's see if that's the case.
Great.
Now let's look at it.
It says to me the background is dark gray.
I know I want to change some things in the label.
I'm going to to my action and my action I'm when I say my label the background color is you eye color
that orange and I'm gonna say my label the text color is going to be you eye color dot black and I'm
going to say my label doesn't text alignment.
Now here's a bit of a difficult one.
We don't know what we should feed to a text alignment.
I kind of knew that this is a color and that I would use the operation the auto completion of ex-coach
tells me hey these are the colors and that's you know kind of you know expect that.
But what about text alignment.
It tells me you have to feed me with something called and there's text alignment.
So I'm going to say OK so.
And that's text align and that's text and lineman's and then and then I thought the dot operation under
some very familiar names center justified left Nashar blah blah I'm going to use the Center for here.
I want to get I say my label dot font.
And it says you have to give me a new iPhone.
I'm going to say it's you I want to dot and then here one of them the when I know I want to use is called
System font of size.
And I want to use a larger font let's say 26 I want to make it a lot larger.
And finally I want to say my labels don't text or text alignment text itself and you see it here and
here says you have to give me a string an optional list thing because it could be nil.
So I'm going to say text is going to be hello hello.
So if it works I'm sure you can guess what we are going to see.
Once my application launches on my iOS 8 simulator hits me Hallsworth.
So that's about that vus are strafed with iOS very similar to how we did Objective-C.
Swift is a lot easier to learn and to work through.
There's a lot easier to are to together started with things that you need to remember is not unlike
Objective-C Strief doesn't have two files in and yet is only one file that is you can two or three if
you do all of your declarations up there and then you have your functions on your life cycles and then
everything is the only primary difference is things are based on a dot operation.
If you want to get the same thing in Objective-C we had to say something like you I fonds and then that
space system a font of size and then do something like you know close the brackets in here.
But since this we used to just use the dot operation you want that system a font and it sticks in my
data center.
You control the state data normal which truly simplifies our process.
Color dot dark gray as opposed to saying you eye color is space dark gray.
So that's about that.
Let's keep that in mind and we'll move on to our next lesson.