Hey everybody what's going on this is Caleb with Dev slopes dot com and in this video we're going to
go ahead and write some help for functions that's going to basically assist us in flipping the lock
status of a certain note when we tap the lock button and we're also going to go ahead and set it so
that when we return back to the note Visi we can update the table view and show the cells with their
new lock status.
So let's go ahead and open our project like so.
And let's go ahead and create a new Swift file in the helper's folder right click click new file swift
file and let's call this helpers OK and press create.
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
a function called is note locked and that's going to return either true or false to help us determine
if a node is locked or not.
And that's what's going to help us know whether we should call Touch ID to pop up.
We're also going to create a function called Lock status flipper that we're going to pass in a lock
status and it's going to return the opposite.
So let's write those functions now because they're really helpful for us.
So first we're going to write phunk is note locked.
OK.
And we're going to pass in a lock status of type lock status and we're going to return a boolean.
OK.
True or false.
Now if lock status was the one with the lowercase L is equal to locked.
We're going to go ahead and return true because the note is locked right.
That's our function.
Otherwise we're going to return false.
Ok just like that.
So function.
Done.
Easy peasy.
If the node is locked we're going to return true.
Otherwise we're going to return false.
Next we're going to create a function called Lock status flipper.
That's going to allow us to pass in a lock status and it'll return the opposite for us.
So go ahead and call phunk lock status flipper.
We're going to pass in a lock status of type lock status and we're going to return a lock status.
Now if lock status is locked we're going to return unlocked.
OK.
Otherwise we're going to return locked what's locked
because if it comes in it's unlocked then we're going to return locked.
Now this is going to help us to set the value of our note to have a new locked status.
So let's think about what we're doing here.
We go to main storyboard.
A note is locked and it already shows up is locked.
But let's say I select the lock note button.
Ok we set up notes array.
We set the note that we selected we set its lock status to be equal to locked.
But it's a little more elegant to call our lock status flipper.
Let's build to make sure we get access to that.
Locks that is flipper and we'll pass in.
Note that lock status.
OK so whatever the status of the note is it's going to flip it.
And in our case it's unlocked so we're going to return locked.
Pretty cool.
So now we can successively lock our notes.
But what we need to do is set up our note VC to reload the table view after we do that because remember
when we tap locknut it dismisses the view.
And so in view will appear if you will appear call super dot view will appear pass in animated.
And what we're going to do is we're just going to go ahead and call table view reload data and that'll
reload all the cells that will reload all their data that's been set and it should show a locked note.
So let's go ahead and try it.
Let's build and run.
Let's see how we did.
And then we're going to be able to go ahead and head over to the next video where we're going to be
able to test if a node is locked or not.
Pretty cool stuff.
So let's select a note and when we click lock note it should set the lock status it should reload and
it should show with a lock.
Boom lock status set table view reloaded and now it has a lock status.
It's now locked which is very cool.
In the next video.
Get excited guys we're going to set up touch I.D. We're going to write a function that's going to enable
us to present our touch I.D. or face I.D. pop up.
We're going to be able to authenticate and then based on whether it's successful or not we can do a
bunch of different things.
We will handle some of the errors will present some alerts to show those errors.
It's going to be awesome guys.
Let's head over to the next video and let's do that now.