1
00:00:07,170 --> 00:00:10,650
Hey everybody what's going on this is callup with slopes dot com.

2
00:00:10,770 --> 00:00:17,040
And in this video we're going to set up our project to have several groups to hold the different files

3
00:00:17,040 --> 00:00:21,650
for our model Leor view layer and controller layer of MBC.

4
00:00:21,690 --> 00:00:27,030
So pull open your X code project that we've been working on and what we're actually going to do is set

5
00:00:27,030 --> 00:00:28,800
up some project folders first.

6
00:00:28,800 --> 00:00:33,980
So go ahead and right click on MVC ify me cap'n and you'll see lots of options.

7
00:00:33,990 --> 00:00:40,470
But we want new group OK go ahead and click on new group and you'll see it'll create a folder within

8
00:00:40,470 --> 00:00:41,550
that folder.

9
00:00:41,550 --> 00:00:46,200
Now I like to go in reverse controller view and model because it's going to put the folder on top of

10
00:00:46,200 --> 00:00:47,120
it.

11
00:00:47,340 --> 00:00:49,720
We can drag them however you want later it just saves time.

12
00:00:49,740 --> 00:00:54,360
So anyway go ahead and call this folder controller.

13
00:00:54,360 --> 00:01:02,070
Then right click on our project folder again click new group make a view folder right click again new

14
00:01:02,070 --> 00:01:05,990
group and a model folder suite.

15
00:01:06,000 --> 00:01:13,800
So now we have a folder for each of the components of model view controller and we already have a view

16
00:01:13,800 --> 00:01:15,930
controller file right here.

17
00:01:15,930 --> 00:01:21,810
Now I'm going to go ahead and drag and drop this into the controller folder so that it's in place and

18
00:01:21,870 --> 00:01:25,120
I don't usually like to do anything with these five that are left.

19
00:01:25,170 --> 00:01:28,920
The app delegate I like to leave out so that it's accessible may not storyboard.

20
00:01:28,920 --> 00:01:31,580
I use all the time so I like to keep that out.

21
00:01:31,590 --> 00:01:34,860
I like to keep the assets folder handy in case I need to drag in things.

22
00:01:34,860 --> 00:01:40,080
Same with the launch screen and the info up the list is is used a lot as well so I like to keep these

23
00:01:40,080 --> 00:01:43,200
accessible for when I am programming.

24
00:01:43,200 --> 00:01:48,450
So now we need to go ahead and I just want to show you very quickly we're just going to kind of poke

25
00:01:48,450 --> 00:01:54,510
around the project and I want to explain a few things to you now in the NBC in theory video that we

26
00:01:54,510 --> 00:02:00,690
watched first in this Target topic we talked about that the model contains data it contains a blueprint

27
00:02:00,690 --> 00:02:02,130
on how to build something.

28
00:02:02,250 --> 00:02:08,820
We learned that the view is like a watch face it displays data from the model and it gets that data

29
00:02:08,850 --> 00:02:15,320
because the view controller controls and shares and modifies and updates all of that information.

30
00:02:15,330 --> 00:02:22,950
So in the main storyboard take a look you can see we have a view controller pretty cool right now if

31
00:02:22,950 --> 00:02:30,120
I click on this it is now selected and if I go over here to a helpful tool called the identity Inspector

32
00:02:30,540 --> 00:02:36,600
I can see the identity of this view controller and as you can see here it is View Controller.

33
00:02:36,720 --> 00:02:37,440
Right.

34
00:02:37,500 --> 00:02:40,290
That coincides with View Controller dot Swift.

35
00:02:40,290 --> 00:02:47,610
If this was to be named something else like how about just controller I can go ahead and rename this

36
00:02:47,610 --> 00:02:52,380
controller as well and the file name does it matter as much as the class name.

37
00:02:52,410 --> 00:02:54,610
You know what just because lets delete this too.

38
00:02:55,050 --> 00:03:01,200
And what I can do now is now that the name has changed I can go back into Main storyboard select my

39
00:03:01,200 --> 00:03:07,180
view controller and actually change my class to be controller as I have now modified it.

40
00:03:07,260 --> 00:03:10,950
So if I press enter it will now say controller which is pretty cool.

41
00:03:10,950 --> 00:03:16,890
So as you can see this swift file goes along with this view controller.

42
00:03:17,070 --> 00:03:20,870
So you're probably wondering wait a minute I can see it.

43
00:03:20,910 --> 00:03:22,430
How come this is a view.

44
00:03:22,740 --> 00:03:28,860
Well the view controller is what is displayed on the screen and it handles the presentation of views.

45
00:03:29,010 --> 00:03:34,590
And now if you look right here within the View Controller we have access to the view and this is the

46
00:03:34,590 --> 00:03:37,070
main view of the application.

47
00:03:37,080 --> 00:03:39,230
Pretty cool so that's the main view.

48
00:03:39,330 --> 00:03:42,620
But what if I wanted to drag on something like a label.

49
00:03:42,750 --> 00:03:47,990
If I were to do that and just drop it here this is now inside the main view.

50
00:03:48,090 --> 00:03:54,720
But the interesting thing is is that deep down a label inherits properties from UI view.

51
00:03:54,720 --> 00:03:57,510
So this in a way is also a view.

52
00:03:57,630 --> 00:03:59,610
So we can go ahead and just get rid of that for now.

53
00:03:59,700 --> 00:04:05,940
We can see the controller here is showing the view it'll present the view when we build the app and

54
00:04:06,060 --> 00:04:08,590
the controller controls everything that happens in the view.

55
00:04:08,610 --> 00:04:14,060
Now the model we're not able to use interface builder by the way that's what this is called.

56
00:04:14,100 --> 00:04:18,950
We're not able to use interface builder to deal with the the model.

57
00:04:19,020 --> 00:04:24,000
We have to do that in code and that makes sense because the model should only contain data and it should

58
00:04:24,000 --> 00:04:28,890
only include instructions on how to construct a certain type of something that you want to construct.

59
00:04:29,100 --> 00:04:35,220
So I just wanted to show you briefly how to set up these groups to organize our project as well as how

60
00:04:35,220 --> 00:04:41,550
it works with Interface Builder with the controller with the view and other various views we can add

61
00:04:41,550 --> 00:04:46,650
on we're going to connect them all up so that they can communicate and talk with one another in another

62
00:04:46,650 --> 00:04:49,230
video but for now this is a pretty good start.

63
00:04:49,230 --> 00:04:51,440
We have set up our project successfully.

64
00:04:51,510 --> 00:04:57,750
We have organized it and we have also sort of seen visually how the controller and view interact.

65
00:04:57,750 --> 00:05:02,390
So in the next video we're actually going to dive into creating our model layer.

66
00:05:02,470 --> 00:05:08,060
OK we saw a controller in this video we saw the view a little bit but we're going to dive into the model

67
00:05:08,060 --> 00:05:08,480
there.

68
00:05:08,490 --> 00:05:10,770
It's always a good starting point to start with the data.

69
00:05:10,770 --> 00:05:16,900
The most fundamental core piece of your app is dealing with data the controller and view presenting

70
00:05:16,900 --> 00:05:17,570
that data.

71
00:05:17,680 --> 00:05:18,940
That's easy stuff.

72
00:05:18,940 --> 00:05:21,970
The model though is always a good foundational starting point.

73
00:05:21,970 --> 00:05:25,570
So we're going to head over to that video now and let's build our model.
