1
00:00:07,150 --> 00:00:10,360
Hey buddy what's going on this is Caleb with Depp slopes dot com.

2
00:00:10,360 --> 00:00:16,060
And in this video we're going to go ahead and set up our table view to present the note detail the scene

3
00:00:16,060 --> 00:00:22,120
when we select a note and pass the note over presented in the View Controller and all that good stuff.

4
00:00:22,150 --> 00:00:25,830
So let's go ahead and pull open our project and let's do that now.

5
00:00:25,930 --> 00:00:32,810
So go into note Visi go ahead and maybe make this a little smaller so we can see better.

6
00:00:32,930 --> 00:00:33,620
Looks like we can't.

7
00:00:33,610 --> 00:00:38,630
How about that let's just reduce it and go ahead and let's make some more room.

8
00:00:38,950 --> 00:00:43,450
Go ahead and call a function called did select row at index path.

9
00:00:43,450 --> 00:00:45,930
And this is what's called whenever we tap on a cell.

10
00:00:46,060 --> 00:00:55,710
So what we're going to do is we're going to basically use this to pass the note and present view controller.

11
00:00:55,840 --> 00:00:56,490
OK.

12
00:00:56,800 --> 00:01:02,620
Now in order to successfully do this we need to pass in a note and we need to pass in an index path.

13
00:01:02,830 --> 00:01:06,570
So what we're going to do is we're going to go ahead and create a function called Push.

14
00:01:06,580 --> 00:01:10,850
Note for index path go ahead and type phunk push.

15
00:01:11,170 --> 00:01:16,170
Note for index path Well you know what let's do it.

16
00:01:16,170 --> 00:01:22,880
Swift syle for index path because that's the property that we're actually passing in is an index path.

17
00:01:22,890 --> 00:01:23,610
OK.

18
00:01:24,030 --> 00:01:30,060
And in this function we're going to create an instance of note detail Visi we're going to go ahead and

19
00:01:30,060 --> 00:01:33,270
pass it some data and set that up so that I can do that.

20
00:01:33,270 --> 00:01:40,090
So go ahead and create an instance with guard let like so note detail.

21
00:01:40,110 --> 00:01:41,480
See.

22
00:01:42,330 --> 00:01:48,570
And that's going to be equal to storyboard instantiate view controller with identifier.

23
00:01:49,320 --> 00:01:53,350
And that identifier is note detail we see.

24
00:01:53,430 --> 00:01:58,620
But we have not yet set this and so it would give us a crash at the current moment go ahead and copy

25
00:01:58,620 --> 00:02:07,560
that head into main storyboard select note detail Visi and in the assistant editor or I guess the identity

26
00:02:07,560 --> 00:02:13,620
inspector there is a storyboard ID paste that in press enter and head back into no VC.

27
00:02:13,950 --> 00:02:17,720
So now we have an instance of a view controller.

28
00:02:17,730 --> 00:02:25,860
Now we need to cast it as note detail DC like so this is great but if we cant do this for some reason

29
00:02:25,860 --> 00:02:27,060
we're going to go ahead and call.

30
00:02:27,060 --> 00:02:29,430
Else return.

31
00:02:29,910 --> 00:02:31,560
And we don't need to return anything.

32
00:02:31,560 --> 00:02:37,860
So assuming this works we have an instance of no detailed VC what we're going to do is we're going to

33
00:02:37,860 --> 00:02:44,070
go ahead and set up some data but in no detail we see we don't have any properties that can be set.

34
00:02:44,220 --> 00:02:47,410
So let's do that first go into no detail we see.

35
00:02:47,700 --> 00:02:50,370
And in here we need to set up three properties.

36
00:02:50,370 --> 00:02:51,810
One is a note.

37
00:02:51,810 --> 00:02:54,120
We need an instance of note to display.

38
00:02:54,120 --> 00:02:59,640
We also need an index so that we know if we're going to lock the no we need to know which note at which

39
00:02:59,670 --> 00:03:01,110
index to lock.

40
00:03:01,110 --> 00:03:03,000
Now we also need a lock status.

41
00:03:03,000 --> 00:03:13,020
So go ahead and type var note of type note like so go ahead and create an variable for the index like

42
00:03:13,020 --> 00:03:14,360
so var index.

43
00:03:14,370 --> 00:03:16,230
And that's just going to be of type int.

44
00:03:16,510 --> 00:03:17,090
OK.

45
00:03:17,370 --> 00:03:22,260
And you know what the lock status actually is contained in notes so we're not going to create a separate

46
00:03:22,680 --> 00:03:26,530
variable for the note if that's cool with you guys.

47
00:03:26,550 --> 00:03:27,110
Cool with me.

48
00:03:27,150 --> 00:03:28,260
Now we need to.

49
00:03:28,410 --> 00:03:29,850
Inside you to load.

50
00:03:29,850 --> 00:03:32,910
Set the data for the text you can like so.

51
00:03:32,910 --> 00:03:40,460
So let's go ahead and say note text view that text is equal to note dot message.

52
00:03:40,470 --> 00:03:45,280
All right so the note we pass in we're going to set the text view to have that text.

53
00:03:45,300 --> 00:03:46,350
Pretty cool.

54
00:03:46,350 --> 00:03:48,610
Now we're going to go ahead and also set up lock.

55
00:03:48,610 --> 00:03:50,120
No it was pressed.

56
00:03:50,310 --> 00:03:55,770
And what that's going to do is it's basically going to flip the lock status of whatever note it is because

57
00:03:55,800 --> 00:04:00,060
if we tap on a note that is unlocked it will load the note.

58
00:04:00,270 --> 00:04:00,880
Right.

59
00:04:01,140 --> 00:04:07,010
And it's currently unlocked if we tap the lock button we should set its lock status to locked right.

60
00:04:07,200 --> 00:04:07,740
To do that.

61
00:04:07,740 --> 00:04:13,110
Go ahead and call notes array and you're probably thinking well how do we know what note was passed

62
00:04:13,110 --> 00:04:14,770
in from the table view.

63
00:04:14,850 --> 00:04:21,030
Remember we're going to be passing in an index right so we can say the note from the particular index

64
00:04:21,040 --> 00:04:25,880
and that'll pull out the exact note that we are on which is great.

65
00:04:25,920 --> 00:04:32,350
Now once we have that note we need to set its lock status to be equal to locked.

66
00:04:32,350 --> 00:04:34,720
OK we're going to set it to be locked then.

67
00:04:34,740 --> 00:04:38,820
What we're going to do is we're going to go ahead and call navigation controller because we're in a

68
00:04:38,820 --> 00:04:43,510
navigation controller and we're going to go ahead and call pop view controller.

69
00:04:43,740 --> 00:04:45,450
Animated is true.

70
00:04:45,450 --> 00:04:49,560
And what that's going to do is it's going to go ahead and dismiss back and slide over back to our table

71
00:04:49,560 --> 00:04:51,120
view which is awesome.

72
00:04:51,150 --> 00:04:55,050
So our no detail Visi is now set up to receive data.

73
00:04:55,050 --> 00:04:56,880
We're going to set these two values.

74
00:04:57,030 --> 00:05:01,650
We're going to go ahead and set up note text you that text to have the value of the message from the

75
00:05:01,650 --> 00:05:02,150
note.

76
00:05:02,280 --> 00:05:09,630
So go back into note Visi And now that we have our instance of note detail Visi we can call note detail

77
00:05:09,630 --> 00:05:12,760
Visi dot note.

78
00:05:13,110 --> 00:05:14,770
And where are we going to get that note.

79
00:05:14,880 --> 00:05:21,850
We can do the exact same thing that we did when we called the note from our self-growth index path function

80
00:05:21,870 --> 00:05:24,030
we can pass in the index path.

81
00:05:24,030 --> 00:05:31,080
So go ahead and set this to be equal to notes array and we're going to pull out the note at the index

82
00:05:31,080 --> 00:05:32,210
path that's passed in.

83
00:05:32,220 --> 00:05:34,310
But the index path itself is not going to work.

84
00:05:34,320 --> 00:05:40,100
We need to pass in the index path dot row because that's the integer value for this particular note.

85
00:05:40,100 --> 00:05:42,680
We can pull out the exact note that we want to pass.

86
00:05:42,720 --> 00:05:48,870
Next we're going to go ahead and set the index path like so no detail Visi index.

87
00:05:48,910 --> 00:05:53,760
Remember we need to capture the index and we're going to set that to be equal to the index path that

88
00:05:53,760 --> 00:05:54,060
Roe.

89
00:05:54,060 --> 00:06:01,950
So we actually get that number value passed in so that we know how to set the notes status for the particular

90
00:06:01,950 --> 00:06:04,240
note from that other view controller.

91
00:06:04,560 --> 00:06:10,410
Next what we're going to do is we're going to call navigation controller push view controller and which

92
00:06:10,410 --> 00:06:11,910
view controller are we going to push.

93
00:06:12,090 --> 00:06:13,620
No detail we see.

94
00:06:13,740 --> 00:06:16,800
And we want it to animated so called true.

95
00:06:17,080 --> 00:06:21,850
And now when we push a note we can animate our view controller and it will look really cool.

96
00:06:21,850 --> 00:06:28,500
So let's go ahead and let's actually call this from did select road index path and let's test it.

97
00:06:28,510 --> 00:06:33,750
So push note for index path and we're going to pass in the index path.

98
00:06:33,880 --> 00:06:34,500
That's it.

99
00:06:34,540 --> 00:06:36,570
Let's go test it build and run.

100
00:06:36,580 --> 00:06:44,860
Let's see how we did.

101
00:06:44,990 --> 00:06:45,360
All right.

102
00:06:45,360 --> 00:06:45,900
Here we go.

103
00:06:45,900 --> 00:06:49,100
So select a note and look at that.

104
00:06:49,260 --> 00:06:51,860
It passes it right in that is so cool.

105
00:06:51,900 --> 00:06:53,820
I love learning about Touch ID and.

106
00:06:54,050 --> 00:06:55,770
And if we click back it goes back.

107
00:06:55,770 --> 00:07:00,520
Now of course our notes are not yet locked but guys we are able to pass notes from view controller view

108
00:07:00,540 --> 00:07:01,740
controller.

109
00:07:01,740 --> 00:07:05,510
I really don't like that this has secure nodes and it's blue.

110
00:07:05,880 --> 00:07:13,770
So let's go ahead and let's fix that by first giving an explicit back button title.

111
00:07:13,770 --> 00:07:18,480
So we're going to go ahead and select our navigation bar up at the top and for the Back button we'll

112
00:07:18,480 --> 00:07:19,860
just type back.

113
00:07:20,030 --> 00:07:21,020
OK.

114
00:07:21,270 --> 00:07:25,560
And what we're going to do is we're going to go ahead and set the tent to be yellow.

115
00:07:25,830 --> 00:07:26,340
OK.

116
00:07:26,550 --> 00:07:31,330
And by doing that it's going to set every button that is you know coming from this to be also yellow.

117
00:07:31,350 --> 00:07:33,330
So build and run let's make sure that that worked.

118
00:07:33,340 --> 00:07:34,880
And that fixed our issue.

119
00:07:35,190 --> 00:07:36,890
Then we're going to go ahead and move on.

120
00:07:37,200 --> 00:07:39,070
OK so let's select the note.

121
00:07:39,300 --> 00:07:39,740
OK good.

122
00:07:39,780 --> 00:07:43,440
We've got a yellow back button with the word back that's perfect.

123
00:07:43,440 --> 00:07:45,570
Very very cool stuff.

124
00:07:45,570 --> 00:07:46,800
Let's think what do we need to do now.

125
00:07:46,850 --> 00:07:52,410
We passed no data to our detail Visi we're displaying it there which looks awesome.

126
00:07:52,410 --> 00:07:53,400
Very very cool stuff.

127
00:07:53,400 --> 00:07:59,610
We can select it we can go back you know what I think this is great guys but what we're going to do

128
00:07:59,670 --> 00:08:04,310
is we're going to set when we tap on lock note K dismisses and goes back.

129
00:08:04,320 --> 00:08:10,890
That's great but we need to set it so that it actually updates the lock status reloads the table view

130
00:08:11,130 --> 00:08:14,420
and shows our new locked cell.

131
00:08:14,590 --> 00:08:17,600
OK then we're going to move on to touch I.D. and face ID.

132
00:08:17,600 --> 00:08:21,790
Very cool we had to build the up first and now we're going to integrate the Touch ID framework's.

133
00:08:21,900 --> 00:08:26,910
So let's go ahead let's head over to the next video where we're going to write some helper functions

134
00:08:27,150 --> 00:08:29,970
and we're going to use that to update our notes cell.

135
00:08:30,060 --> 00:08:31,570
All right let's head over there now.
