1
00:00:06,290 --> 00:00:08,660
What's up everyone heartbreaker that's slopes.

2
00:00:08,690 --> 00:00:14,570
Dot com let's just dive right in in the last video we got segues working and we got our unwind Segway

3
00:00:14,570 --> 00:00:20,810
working super easy to switch back and forth between screens like super super easy no code even required

4
00:00:20,810 --> 00:00:22,220
which is really cool.

5
00:00:22,220 --> 00:00:27,260
And in this video we want to get our view controllers finished being set up but we don't actually have

6
00:00:27,260 --> 00:00:30,770
code for them and things like that and we get some other weird things going on that we want to fix.

7
00:00:30,770 --> 00:00:32,790
Refactoring some names and stuff.

8
00:00:32,910 --> 00:00:34,110
Ocelots do all that stuff.

9
00:00:34,220 --> 00:00:38,270
But first things first I'm going to go ahead and get status to see what's changed.

10
00:00:38,270 --> 00:00:47,290
I have some changes to add Desch a good commit dash em and we're going to say segues and on and just

11
00:00:47,480 --> 00:00:50,440
check my branch get checked out.

12
00:00:50,540 --> 00:00:51,680
OK so that was less than five.

13
00:00:51,680 --> 00:01:01,210
So let's let's actually let's actually push this up first so get committed so get push Orjan.

14
00:01:01,400 --> 00:01:04,390
Lesson 0 5.

15
00:01:08,740 --> 00:01:09,290
Wonderful.

16
00:01:09,310 --> 00:01:16,090
And just to be sure I don't think I push my lesson for branchial get check out lesson 0 4.

17
00:01:16,090 --> 00:01:19,420
If you're if you're wondering Mark why are you showing us this stuff.

18
00:01:19,420 --> 00:01:24,400
Well I found that if I don't show you the professional things that we do on a regular basis when you

19
00:01:24,400 --> 00:01:29,350
actually go to encounter at a job your IT guy who interviewed you or you get your brand new boss who

20
00:01:29,350 --> 00:01:31,300
is like wait a minute why didn't you ever learn get.

21
00:01:31,300 --> 00:01:33,610
That is so important and you're like well I just took this course.

22
00:01:33,610 --> 00:01:37,810
They did teach me well if you're taking a sip of course of course we're going to teach you.

23
00:01:37,810 --> 00:01:40,130
And so I leave the stuff in.

24
00:01:40,150 --> 00:01:43,180
OK get push origin.

25
00:01:43,180 --> 00:01:45,090
When you say lesson 0 4

26
00:01:50,290 --> 00:01:53,440
and here's something interesting so maybe you're thinking will mark now.

27
00:01:53,440 --> 00:01:56,980
Now you can check out lesson 0 6 right.

28
00:01:57,100 --> 00:01:57,750
OK.

29
00:01:58,000 --> 00:02:01,830
We were on lesson five and let's just check out the six.

30
00:02:01,830 --> 00:02:06,100
Well we don't want to do that because we would be creating a code from the lesson for Branch and it

31
00:02:06,100 --> 00:02:07,250
would be outdated.

32
00:02:07,270 --> 00:02:13,530
So we actually need to first do is get check out less and lessoned 05.

33
00:02:14,200 --> 00:02:16,620
What did I do here.

34
00:02:16,690 --> 00:02:17,860
We pushed.

35
00:02:17,860 --> 00:02:18,650
That's fine.

36
00:02:21,370 --> 00:02:26,450
We would just stash just something changed on it just by nature having the file open which is fine.

37
00:02:26,510 --> 00:02:26,810
So good.

38
00:02:26,820 --> 00:02:29,750
Check out lesson 0 5.

39
00:02:29,760 --> 00:02:30,780
So check out that first.

40
00:02:30,810 --> 00:02:32,180
And now we'll create the new branch get.

41
00:02:32,190 --> 00:02:35,600
Check out Desch be less than this 0 6.

42
00:02:35,620 --> 00:02:36,890
OK.

43
00:02:37,200 --> 00:02:39,230
So a little bit of get magic you're going see a lot of this.

44
00:02:39,510 --> 00:02:43,920
And another question I get a lot when teaching these lessons is Mark why are you using the standard

45
00:02:43,920 --> 00:02:44,560
terminal.

46
00:02:44,610 --> 00:02:48,820
Don't you know there's all kinds of cool tools in hackery and stuff you can do.

47
00:02:48,820 --> 00:02:53,310
You can sure get branch away from the terminal and you can have pretty colors and do hockeys and all

48
00:02:53,310 --> 00:02:53,800
that stuff.

49
00:02:53,800 --> 00:02:58,440
Well I don't do any of that stuff because I got to teach it and you guys won't have that stuff.

50
00:02:58,440 --> 00:03:01,160
And secondly I actually don't even use those things in my own development.

51
00:03:01,170 --> 00:03:04,160
I just like keeping everything base and clean.

52
00:03:04,620 --> 00:03:08,020
And maybe that's the Teach for me but I just like things beyond being pure and clean.

53
00:03:08,060 --> 00:03:13,500
It's weird but that's why so command made it clear all this mess up we are on Branch the proper branch

54
00:03:13,530 --> 00:03:17,610
now and we've got two or three new controllers in here which is great the Segway is in place.

55
00:03:17,610 --> 00:03:22,200
And so what I want to do is I want to rename this view controller and I want to set up some folders

56
00:03:22,200 --> 00:03:22,560
here.

57
00:03:22,560 --> 00:03:28,600
We probably should have called this view set of views and I would create a couple more groups here.

58
00:03:28,740 --> 00:03:35,100
So a new group we're going to call this controller and a new group called model for model view controller.

59
00:03:35,200 --> 00:03:37,720
OK and I like to put all the files where they need to be.

60
00:03:37,770 --> 00:03:38,820
So model.

61
00:03:39,280 --> 00:03:39,800
OK.

62
00:03:39,810 --> 00:03:43,090
And this controller file we should move into the controller folder.

63
00:03:43,100 --> 00:03:46,040
So controllers going and controller and this name is really bad.

64
00:03:46,050 --> 00:03:46,990
It's not descriptive.

65
00:03:47,010 --> 00:03:47,620
OK.

66
00:03:47,700 --> 00:03:50,460
Everything you do in coding should be very descriptive.

67
00:03:50,520 --> 00:03:53,820
You know I've worked with programmers who just like make the most obscure names and they take all the

68
00:03:53,820 --> 00:03:56,500
spaces out and literally where do you have no idea what's going on.

69
00:03:56,550 --> 00:04:01,490
Why do you think Apple always has like super long function names like an one from Segway.

70
00:04:01,500 --> 00:04:04,710
It's because they want you to understand it doesn't matter how long it is.

71
00:04:04,710 --> 00:04:08,060
So let's go to our view controller swift and let's rename it.

72
00:04:08,060 --> 00:04:10,890
So double click the name after class.

73
00:04:10,890 --> 00:04:11,980
OK that's our custom name.

74
00:04:12,000 --> 00:04:14,490
Right click it and go to rename.

75
00:04:14,520 --> 00:04:15,080
All right.

76
00:04:15,150 --> 00:04:17,810
This is a really cool new thing in X code 9.

77
00:04:17,830 --> 00:04:20,100
It could refactor everything for you.

78
00:04:20,100 --> 00:04:24,780
So what we're going to do is we notice how even in the storyboard it's reference it's going to rename

79
00:04:24,780 --> 00:04:26,570
that so we don't have to reconnect anything.

80
00:04:26,580 --> 00:04:28,530
So that is just awesome.

81
00:04:28,560 --> 00:04:35,040
So what we're going to do is we're going to call this what is this welcome screen so welcome.

82
00:04:35,040 --> 00:04:37,050
VC I always put VC at the end.

83
00:04:37,050 --> 00:04:38,790
Apple likes to put the whole world view controller.

84
00:04:38,790 --> 00:04:39,660
That's kind of pointless.

85
00:04:39,660 --> 00:04:44,670
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

86
00:04:44,670 --> 00:04:50,130
that it's a controller file and not like a button file view or a model file so just press enter and

87
00:04:50,130 --> 00:04:52,030
it's now refactored it as it should be.

88
00:04:52,080 --> 00:04:52,950
Which is great.

89
00:04:53,310 --> 00:04:53,900
OK.

90
00:04:54,030 --> 00:04:55,690
So there are welcome visi.

91
00:04:55,710 --> 00:05:00,480
And the next thing I want to do is create two more view controllers OK one for each of our of our view

92
00:05:00,480 --> 00:05:01,430
controllers here.

93
00:05:01,680 --> 00:05:07,830
So right now just by having these in Interface Builder what's happening under the hood is Apple on iOS

94
00:05:07,890 --> 00:05:12,900
is creating a view controller with code like default implementation code.

95
00:05:12,900 --> 00:05:18,900
So if we look at our view controller here OK what it's doing is basically that you have your control.

96
00:05:18,900 --> 00:05:20,850
It's implementing just an empty blank one.

97
00:05:20,880 --> 00:05:27,210
So no custom code and it wouldn't have any of this stuff and it just boilerplate stuff that's happening

98
00:05:27,240 --> 00:05:31,120
underneath the hood because your views here actually can't run without code.

99
00:05:31,170 --> 00:05:34,950
So you may think there's you may think there's no code but there actually is code going on under the

100
00:05:34,950 --> 00:05:35,610
hood.

101
00:05:35,610 --> 00:05:40,770
Apple's just doing that for us automatically and it's not useful to us because we can't actually connect

102
00:05:40,770 --> 00:05:42,310
to buttons and things like that.

103
00:05:42,660 --> 00:05:44,650
So we need a view controller for both of these.

104
00:05:44,760 --> 00:05:45,030
OK.

105
00:05:45,030 --> 00:05:47,690
So for the league VC and the skill of VC.

106
00:05:47,790 --> 00:05:54,930
So in the controller folder we're going to go to new file Cocco touch class because we need a blank

107
00:05:54,930 --> 00:06:02,920
so far but an actual Cocco touch or UI kit class for for iOS UI you control is what we want in the subclass

108
00:06:02,920 --> 00:06:04,340
to make sure it says that there.

109
00:06:04,720 --> 00:06:07,580
And let's call this one league visi.

110
00:06:08,060 --> 00:06:10,240
We don't we do not want to also create a zip file.

111
00:06:10,240 --> 00:06:14,480
This would create an extra interface file for this view controller we already have one here in our interface

112
00:06:14,480 --> 00:06:26,360
builder so click next and create all right and let's create a second one so new file Coqui touch class

113
00:06:26,670 --> 00:06:32,800
and we're going to call this one skill Visi and again make sure you have your controller is the subclass.

114
00:06:32,820 --> 00:06:36,120
OK so now we have these extra two view controllers.

115
00:06:36,450 --> 00:06:40,900
But now we need to connect them in our storyboard and that's fairly simple as well.

116
00:06:40,980 --> 00:06:45,900
So remember right now because we just drag these an interface builder when the app goes at runtime it's

117
00:06:45,900 --> 00:06:49,200
creating a standard view controller with none of our custom code in it.

118
00:06:49,200 --> 00:06:50,300
We want to change that.

119
00:06:50,490 --> 00:06:55,080
So all you have to do is over here on the left hand side in the document outline select the view control

120
00:06:55,080 --> 00:06:59,150
that you want which is this one here and this is our league controller.

121
00:06:59,250 --> 00:07:03,310
And then on the right hand side over here there's a little icon here called the identity inspector.

122
00:07:03,330 --> 00:07:06,690
Click that and see other classes you have your controller.

123
00:07:06,690 --> 00:07:11,670
All you have to do is change this to your league visi.

124
00:07:12,120 --> 00:07:14,560
And the important thing to know is you can't put anything in here.

125
00:07:14,580 --> 00:07:19,830
It has to be code that inherits from you have you control this colon here.

126
00:07:19,860 --> 00:07:24,810
And the word you gave you control or after means your custom class your custom view controller is inheriting

127
00:07:24,810 --> 00:07:26,470
from the base View Controller.

128
00:07:26,580 --> 00:07:28,280
If it doesn't this would not work.

129
00:07:28,290 --> 00:07:29,570
It would not have let us pick this.

130
00:07:29,580 --> 00:07:31,680
That's a very important thing to understand.

131
00:07:31,760 --> 00:07:32,370
OK.

132
00:07:32,730 --> 00:07:33,950
And let's click next.

133
00:07:33,960 --> 00:07:37,410
Your controller on the right hand side over here is highlighted over here.

134
00:07:37,440 --> 00:07:40,850
Identity inspector and let's change this one to the skill of the see.

135
00:07:41,350 --> 00:07:41,580
OK.

136
00:07:41,590 --> 00:07:43,170
So these are now connected.

137
00:07:43,170 --> 00:07:44,430
They're now connected to the code.

138
00:07:44,430 --> 00:07:49,650
So when I say we select this one right here and we click the assistant editor it's automatically going

139
00:07:49,650 --> 00:07:54,020
to pull open the league Visi code so we can create Iby actions and things like that.

140
00:07:54,270 --> 00:07:54,820
OK.

141
00:07:55,080 --> 00:07:57,140
So we've now got our our code cleaned up.

142
00:07:57,140 --> 00:08:01,000
What we've done is we've created some folders here controller we've connected them to the store board

143
00:08:01,030 --> 00:08:06,510
and this is how you do your apps whenever you're dragging interface a file or view controller files

144
00:08:06,570 --> 00:08:07,470
and the interface builder.

145
00:08:07,470 --> 00:08:11,940
You have to go and create the controller code for and a lot of new people forget that they build all

146
00:08:11,940 --> 00:08:16,600
the interface like well I can't find that code for it because you didn't create the code for it.

147
00:08:16,830 --> 00:08:23,940
And you also one more one more rookie mistake though a lot of people make is they will go into the View

148
00:08:23,940 --> 00:08:27,050
Controller and they'll create a new Swift file like this.

149
00:08:27,150 --> 00:08:27,790
OK.

150
00:08:27,810 --> 00:08:33,480
And there is the call this you know my Visi and it's empty and they're like what's going on over I should

151
00:08:33,480 --> 00:08:39,750
probably create a class and we'll call this you know my Visi and let's inherit from you view controller

152
00:08:39,780 --> 00:08:41,330
and you think oh this is great.

153
00:08:41,460 --> 00:08:42,250
All right.

154
00:08:42,480 --> 00:08:46,520
But use of undeclared type you have you control or what's going on.

155
00:08:46,540 --> 00:08:47,740
It's why is it not working.

156
00:08:47,740 --> 00:08:48,730
I don't know.

157
00:08:48,730 --> 00:08:49,690
This happens all the time.

158
00:08:49,690 --> 00:08:51,830
I see people give me questions on this all the time.

159
00:08:51,910 --> 00:08:57,460
Well the problem is when you create a swift file it's importing Foundation which is just the code for

160
00:08:57,460 --> 00:08:58,360
swift.

161
00:08:58,360 --> 00:09:03,430
It does not have cocoa touch all the frameworks that Apple has built for us for iOS development does

162
00:09:03,430 --> 00:09:04,530
not exist.

163
00:09:04,540 --> 00:09:11,620
So in order for this to work you have to import UI it like so you why Kit includes the foundation which

164
00:09:11,620 --> 00:09:16,990
has swift code in it but also it includes all of the Iowa stuff like you have your controller and that's

165
00:09:16,990 --> 00:09:18,590
a problem that a lot of people make.

166
00:09:18,670 --> 00:09:20,700
So don't do that.

167
00:09:21,070 --> 00:09:23,730
Or make sure you do it there.

168
00:09:23,730 --> 00:09:25,230
So a lot of good stuff here.

169
00:09:25,240 --> 00:09:28,540
We're going to call this video down a little bit short but it's important for you to digest what just

170
00:09:28,540 --> 00:09:29,440
happened here.

171
00:09:29,560 --> 00:09:32,310
And let's go ahead and move on forward into the next video.
