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