1
00:00:07,070 --> 00:00:11,950
Hey everybody what's going on this is Caleb with Dev slopes dot com and in this video we're going to

2
00:00:11,950 --> 00:00:17,470
go ahead and write some help for functions that's going to basically assist us in flipping the lock

3
00:00:17,470 --> 00:00:22,690
status of a certain note when we tap the lock button and we're also going to go ahead and set it so

4
00:00:22,690 --> 00:00:28,240
that when we return back to the note Visi we can update the table view and show the cells with their

5
00:00:28,240 --> 00:00:29,410
new lock status.

6
00:00:29,410 --> 00:00:32,340
So let's go ahead and open our project like so.

7
00:00:32,650 --> 00:00:39,040
And let's go ahead and create a new Swift file in the helper's folder right click click new file swift

8
00:00:39,040 --> 00:00:43,890
file and let's call this helpers OK and press create.

9
00:00:43,960 --> 00:00:49,870
Now what we're going to do in this in this file is we're going to basically for one we're going to set

10
00:00:50,140 --> 00:00:55,270
a function called is note locked and that's going to return either true or false to help us determine

11
00:00:55,270 --> 00:00:56,570
if a node is locked or not.

12
00:00:56,680 --> 00:01:01,200
And that's what's going to help us know whether we should call Touch ID to pop up.

13
00:01:01,210 --> 00:01:06,910
We're also going to create a function called Lock status flipper that we're going to pass in a lock

14
00:01:06,910 --> 00:01:09,130
status and it's going to return the opposite.

15
00:01:09,130 --> 00:01:12,280
So let's write those functions now because they're really helpful for us.

16
00:01:12,280 --> 00:01:17,620
So first we're going to write phunk is note locked.

17
00:01:18,290 --> 00:01:18,930
OK.

18
00:01:19,220 --> 00:01:27,500
And we're going to pass in a lock status of type lock status and we're going to return a boolean.

19
00:01:27,500 --> 00:01:27,740
OK.

20
00:01:27,740 --> 00:01:28,760
True or false.

21
00:01:28,760 --> 00:01:36,980
Now if lock status was the one with the lowercase L is equal to locked.

22
00:01:36,980 --> 00:01:40,100
We're going to go ahead and return true because the note is locked right.

23
00:01:40,100 --> 00:01:41,460
That's our function.

24
00:01:42,020 --> 00:01:44,580
Otherwise we're going to return false.

25
00:01:44,700 --> 00:01:45,580
Ok just like that.

26
00:01:45,590 --> 00:01:46,530
So function.

27
00:01:46,550 --> 00:01:46,940
Done.

28
00:01:46,940 --> 00:01:47,940
Easy peasy.

29
00:01:47,990 --> 00:01:50,510
If the node is locked we're going to return true.

30
00:01:50,510 --> 00:01:53,210
Otherwise we're going to return false.

31
00:01:53,210 --> 00:01:56,540
Next we're going to create a function called Lock status flipper.

32
00:01:56,660 --> 00:02:00,920
That's going to allow us to pass in a lock status and it'll return the opposite for us.

33
00:02:00,920 --> 00:02:06,110
So go ahead and call phunk lock status flipper.

34
00:02:06,230 --> 00:02:15,860
We're going to pass in a lock status of type lock status and we're going to return a lock status.

35
00:02:15,950 --> 00:02:22,700
Now if lock status is locked we're going to return unlocked.

36
00:02:23,380 --> 00:02:23,740
OK.

37
00:02:23,750 --> 00:02:29,370
Otherwise we're going to return locked what's locked

38
00:02:32,330 --> 00:02:35,180
because if it comes in it's unlocked then we're going to return locked.

39
00:02:35,180 --> 00:02:42,160
Now this is going to help us to set the value of our note to have a new locked status.

40
00:02:42,410 --> 00:02:44,200
So let's think about what we're doing here.

41
00:02:44,270 --> 00:02:46,120
We go to main storyboard.

42
00:02:46,370 --> 00:02:48,670
A note is locked and it already shows up is locked.

43
00:02:48,680 --> 00:02:51,590
But let's say I select the lock note button.

44
00:02:51,740 --> 00:02:55,580
Ok we set up notes array.

45
00:02:55,610 --> 00:02:59,480
We set the note that we selected we set its lock status to be equal to locked.

46
00:02:59,830 --> 00:03:04,830
But it's a little more elegant to call our lock status flipper.

47
00:03:05,090 --> 00:03:07,960
Let's build to make sure we get access to that.

48
00:03:08,140 --> 00:03:10,920
Locks that is flipper and we'll pass in.

49
00:03:11,060 --> 00:03:12,900
Note that lock status.

50
00:03:12,960 --> 00:03:15,470
OK so whatever the status of the note is it's going to flip it.

51
00:03:15,680 --> 00:03:18,560
And in our case it's unlocked so we're going to return locked.

52
00:03:18,590 --> 00:03:19,820
Pretty cool.

53
00:03:19,820 --> 00:03:23,650
So now we can successively lock our notes.

54
00:03:23,800 --> 00:03:30,590
But what we need to do is set up our note VC to reload the table view after we do that because remember

55
00:03:30,920 --> 00:03:33,240
when we tap locknut it dismisses the view.

56
00:03:33,410 --> 00:03:40,960
And so in view will appear if you will appear call super dot view will appear pass in animated.

57
00:03:41,150 --> 00:03:45,400
And what we're going to do is we're just going to go ahead and call table view reload data and that'll

58
00:03:45,440 --> 00:03:50,930
reload all the cells that will reload all their data that's been set and it should show a locked note.

59
00:03:50,930 --> 00:03:52,050
So let's go ahead and try it.

60
00:03:52,070 --> 00:03:53,420
Let's build and run.

61
00:03:53,540 --> 00:03:54,720
Let's see how we did.

62
00:03:55,190 --> 00:03:59,600
And then we're going to be able to go ahead and head over to the next video where we're going to be

63
00:03:59,600 --> 00:04:02,270
able to test if a node is locked or not.

64
00:04:02,270 --> 00:04:03,470
Pretty cool stuff.

65
00:04:03,470 --> 00:04:09,320
So let's select a note and when we click lock note it should set the lock status it should reload and

66
00:04:09,320 --> 00:04:10,840
it should show with a lock.

67
00:04:12,220 --> 00:04:18,030
Boom lock status set table view reloaded and now it has a lock status.

68
00:04:18,040 --> 00:04:20,140
It's now locked which is very cool.

69
00:04:20,230 --> 00:04:21,370
In the next video.

70
00:04:21,370 --> 00:04:27,040
Get excited guys we're going to set up touch I.D. We're going to write a function that's going to enable

71
00:04:27,040 --> 00:04:31,270
us to present our touch I.D. or face I.D. pop up.

72
00:04:31,270 --> 00:04:36,550
We're going to be able to authenticate and then based on whether it's successful or not we can do a

73
00:04:36,550 --> 00:04:37,360
bunch of different things.

74
00:04:37,360 --> 00:04:40,810
We will handle some of the errors will present some alerts to show those errors.

75
00:04:40,930 --> 00:04:41,790
It's going to be awesome guys.

76
00:04:41,830 --> 00:04:45,320
Let's head over to the next video and let's do that now.
