1
00:00:07,170 --> 00:00:12,150
Hey buddy what's going on this is Caleb with slopes dot com and in this video we're going to go ahead

2
00:00:12,150 --> 00:00:18,150
and create our no model but we're also going to create some dummy data to load in our table view and

3
00:00:18,150 --> 00:00:24,360
we're also going to create an enumeration called Lock status to help us determine whether or not a cell

4
00:00:24,480 --> 00:00:26,130
should show a particular image or not.

5
00:00:26,130 --> 00:00:30,160
So go ahead and pull open your X code project just like so.

6
00:00:30,420 --> 00:00:34,380
And what we're going to do is we're going to right click on our model folder we're going to go ahead

7
00:00:34,380 --> 00:00:37,980
and click new file and we're going to create a swift file.

8
00:00:38,000 --> 00:00:42,950
So click on swift click on next and go ahead and name this note.

9
00:00:43,210 --> 00:00:44,090
OK.

10
00:00:44,430 --> 00:00:45,300
Create it.

11
00:00:45,660 --> 00:00:51,630
And now what we can do is we can create a class called note we can create some properties and we can

12
00:00:51,630 --> 00:00:54,010
also go ahead and initialize them.

13
00:00:54,030 --> 00:00:58,340
So call a class note like so.

14
00:00:58,800 --> 00:01:03,390
And now inside we're going to create two properties message and lock status.

15
00:01:03,390 --> 00:01:08,520
The message of course is going to be the text of the note and the lock status is going to be either

16
00:01:08,610 --> 00:01:09,950
locked or unlocked.

17
00:01:10,020 --> 00:01:10,650
OK.

18
00:01:11,250 --> 00:01:16,820
So go ahead and call public private set

19
00:01:19,750 --> 00:01:23,220
var message ok of type string.

20
00:01:23,380 --> 00:01:29,110
And the reason we're using public private set is because we want the message to be publicly accessible

21
00:01:29,440 --> 00:01:34,600
but we don't want to be able to change the message from any other class other than this one when we

22
00:01:34,600 --> 00:01:35,830
create the note.

23
00:01:35,830 --> 00:01:38,790
Now that's not the same for the lock status.

24
00:01:38,800 --> 00:01:41,970
OK the lock status we do want to be able to change.

25
00:01:41,980 --> 00:01:47,180
So for that one I'm just going to go ahead and call this public var lock status.

26
00:01:47,290 --> 00:01:50,510
But this needs to be of a custom type.

27
00:01:50,650 --> 00:01:56,200
We need an enumeration called Lock status that has two cases locked and unlocked.

28
00:01:56,200 --> 00:02:06,670
So right click on the anime's folder and click new file click swift file name it lock status and press

29
00:02:06,670 --> 00:02:07,920
create.

30
00:02:07,930 --> 00:02:15,130
Now inside this we're going to go ahead and just say ENM lock status and we're going to go ahead and

31
00:02:15,130 --> 00:02:20,110
create two cases like I said case locked and case unlocked.

32
00:02:20,430 --> 00:02:20,930
OK.

33
00:02:21,460 --> 00:02:25,240
So now we can give it a value locked or unlocked.

34
00:02:25,300 --> 00:02:27,610
Pretty cool to go into note.

35
00:02:27,610 --> 00:02:34,030
Go ahead and give it a lock status of type lock status and of course that may not show up until you

36
00:02:34,030 --> 00:02:35,220
build the project.

37
00:02:35,410 --> 00:02:36,820
As you can see it is now.

38
00:02:37,120 --> 00:02:40,570
But now it's complaining that we have no initializers.

39
00:02:40,570 --> 00:02:42,600
So go ahead and call in.

40
00:02:42,610 --> 00:02:52,030
Like so pasan a message of type String pass in a lock status of type lock status like so then we're

41
00:02:52,030 --> 00:02:58,990
going to set self Dopp message to be equal to message and self-doubt lock status to be equal to lock

42
00:02:58,990 --> 00:03:00,370
status just like that.

43
00:03:00,560 --> 00:03:07,130
OK so now we have a note class that we can use to create an instance of note and we're going to do that.

44
00:03:07,120 --> 00:03:11,170
So let's go ahead and let's go into our helper's folder like so.

45
00:03:11,530 --> 00:03:14,840
And we're going to create a new file.

46
00:03:14,870 --> 00:03:18,910
So go ahead and create a swift file and we're going to just call this note.

47
00:03:19,080 --> 00:03:23,140
Objects can go ahead and click create to create that.

48
00:03:23,340 --> 00:03:28,770
OK so what we're going to do is we're just going to create an array of three instances of note.

49
00:03:28,800 --> 00:03:32,880
And this is going to be our static data that we're going to use to fill our table view.

50
00:03:32,880 --> 00:03:36,990
Now of course this app would be much better if you could add your own notes and you could save them

51
00:03:36,990 --> 00:03:40,060
using Core data or some other persistence method.

52
00:03:40,060 --> 00:03:44,480
But just for the purposes of this app we've got to get to touch I.D. and face I.D. soon.

53
00:03:44,490 --> 00:03:51,420
So I'm just going to make some static data to speed things up here so go ahead and write var notes array.

54
00:03:52,260 --> 00:03:54,200
And that's going to be an array of type.

55
00:03:54,200 --> 00:03:59,670
Note we need to explicitly say that it is and that's going to be an array of type note.

56
00:03:59,670 --> 00:04:03,640
So let's create some notes first let's say var.

57
00:04:03,660 --> 00:04:07,010
Note 1 is going to be equal to note.

58
00:04:07,980 --> 00:04:11,020
And we're going to instantiate it with a message and a lock status.

59
00:04:11,040 --> 00:04:20,470
So the message will be dev slopes is a really amazing platform to learn to code.

60
00:04:20,580 --> 00:04:24,750
Check it out at Dev slopes dot com

61
00:04:27,660 --> 00:04:32,730
sweet and let's give it a lock status we're going to set it to be locked by default.

62
00:04:33,190 --> 00:04:34,480
OK let's create a second note.

63
00:04:34,530 --> 00:04:36,430
Var notes too.

64
00:04:36,630 --> 00:04:38,240
It's going to be equal to note.

65
00:04:38,550 --> 00:04:48,000
And we're going to pass in another message so let's say I love learning about Touch ID and face ID at

66
00:04:48,000 --> 00:04:51,090
the same time.

67
00:04:51,090 --> 00:04:58,820
Thanks Apple for making such amazing framework's.

68
00:04:58,910 --> 00:05:02,900
And you know what let's put in a little Moji here just for fun little heart.

69
00:05:02,900 --> 00:05:03,690
There we go.

70
00:05:03,950 --> 00:05:08,790
And we're going to set a lock status of unlocked just because why not.

71
00:05:08,810 --> 00:05:13,410
Now let's make a third instance here var note three equals note.

72
00:05:13,430 --> 00:05:17,040
And of course you could go on and on you could make more than three notes but I'm going to make three

73
00:05:17,990 --> 00:05:18,950
and this will say

74
00:05:22,560 --> 00:05:28,070
all right stop collaborate and listen

75
00:05:31,460 --> 00:05:38,270
devs slopes back with a brand new invention.

76
00:05:39,320 --> 00:05:39,740
Why not.

77
00:05:39,860 --> 00:05:40,510
OK.

78
00:05:40,910 --> 00:05:44,650
And then we're going to set a clock status of locked Let's lock that one down.

79
00:05:45,020 --> 00:05:50,680
So we have three instances of note two with a locked status one with an unlocked status.

80
00:05:50,690 --> 00:05:59,690
And now to create our array we just need to pass in no one comma no two comma and note three.

81
00:05:59,990 --> 00:06:04,760
So now we have a static array of notes that we can use Well OK it's not static.

82
00:06:04,760 --> 00:06:10,610
I haven't declared it is static but it is going to be just an instance that we can use to pull data

83
00:06:10,640 --> 00:06:12,400
and displayed in our table view.

84
00:06:12,440 --> 00:06:18,260
So we're now at a good place to actually move on to creating our notes cell and then setting up our

85
00:06:18,260 --> 00:06:22,300
table view to pull data from this note's array and display it.

86
00:06:22,430 --> 00:06:23,300
Pretty cool stuff.

87
00:06:23,300 --> 00:06:28,910
So let's head over to the next video where we're going to build out notes cell its subclass and we're

88
00:06:28,910 --> 00:06:33,980
going to wire it up with the proper IP outlets that it needs so let's head over that way now and let's

89
00:06:33,980 --> 00:06:35,190
do it.
