Hey buddy what's going on this is Caleb with Depp slopes dot com.
And in this video we're going to go ahead and set up our table view to present the note detail the scene
when we select a note and pass the note over presented in the View Controller and all that good stuff.
So let's go ahead and pull open our project and let's do that now.
So go into note Visi go ahead and maybe make this a little smaller so we can see better.
Looks like we can't.
How about that let's just reduce it and go ahead and let's make some more room.
Go ahead and call a function called did select row at index path.
And this is what's called whenever we tap on a cell.
So what we're going to do is we're going to basically use this to pass the note and present view controller.
OK.
Now in order to successfully do this we need to pass in a note and we need to pass in an index path.
So what we're going to do is we're going to go ahead and create a function called Push.
Note for index path go ahead and type phunk push.
Note for index path Well you know what let's do it.
Swift syle for index path because that's the property that we're actually passing in is an index path.
OK.
And in this function we're going to create an instance of note detail Visi we're going to go ahead and
pass it some data and set that up so that I can do that.
So go ahead and create an instance with guard let like so note detail.
See.
And that's going to be equal to storyboard instantiate view controller with identifier.
And that identifier is note detail we see.
But we have not yet set this and so it would give us a crash at the current moment go ahead and copy
that head into main storyboard select note detail Visi and in the assistant editor or I guess the identity
inspector there is a storyboard ID paste that in press enter and head back into no VC.
So now we have an instance of a view controller.
Now we need to cast it as note detail DC like so this is great but if we cant do this for some reason
we're going to go ahead and call.
Else return.
And we don't need to return anything.
So assuming this works we have an instance of no detailed VC what we're going to do is we're going to
go ahead and set up some data but in no detail we see we don't have any properties that can be set.
So let's do that first go into no detail we see.
And in here we need to set up three properties.
One is a note.
We need an instance of note to display.
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
index to lock.
Now we also need a lock status.
So go ahead and type var note of type note like so go ahead and create an variable for the index like
so var index.
And that's just going to be of type int.
OK.
And you know what the lock status actually is contained in notes so we're not going to create a separate
variable for the note if that's cool with you guys.
Cool with me.
Now we need to.
Inside you to load.
Set the data for the text you can like so.
So let's go ahead and say note text view that text is equal to note dot message.
All right so the note we pass in we're going to set the text view to have that text.
Pretty cool.
Now we're going to go ahead and also set up lock.
No it was pressed.
And what that's going to do is it's basically going to flip the lock status of whatever note it is because
if we tap on a note that is unlocked it will load the note.
Right.
And it's currently unlocked if we tap the lock button we should set its lock status to locked right.
To do that.
Go ahead and call notes array and you're probably thinking well how do we know what note was passed
in from the table view.
Remember we're going to be passing in an index right so we can say the note from the particular index
and that'll pull out the exact note that we are on which is great.
Now once we have that note we need to set its lock status to be equal to locked.
OK we're going to set it to be locked then.
What we're going to do is we're going to go ahead and call navigation controller because we're in a
navigation controller and we're going to go ahead and call pop view controller.
Animated is true.
And what that's going to do is it's going to go ahead and dismiss back and slide over back to our table
view which is awesome.
So our no detail Visi is now set up to receive data.
We're going to set these two values.
We're going to go ahead and set up note text you that text to have the value of the message from the
note.
So go back into note Visi And now that we have our instance of note detail Visi we can call note detail
Visi dot note.
And where are we going to get that note.
We can do the exact same thing that we did when we called the note from our self-growth index path function
we can pass in the index path.
So go ahead and set this to be equal to notes array and we're going to pull out the note at the index
path that's passed in.
But the index path itself is not going to work.
We need to pass in the index path dot row because that's the integer value for this particular note.
We can pull out the exact note that we want to pass.
Next we're going to go ahead and set the index path like so no detail Visi index.
Remember we need to capture the index and we're going to set that to be equal to the index path that
Roe.
So we actually get that number value passed in so that we know how to set the notes status for the particular
note from that other view controller.
Next what we're going to do is we're going to call navigation controller push view controller and which
view controller are we going to push.
No detail we see.
And we want it to animated so called true.
And now when we push a note we can animate our view controller and it will look really cool.
So let's go ahead and let's actually call this from did select road index path and let's test it.
So push note for index path and we're going to pass in the index path.
That's it.
Let's go test it build and run.
Let's see how we did.
All right.
Here we go.
So select a note and look at that.
It passes it right in that is so cool.
I love learning about Touch ID and.
And if we click back it goes back.
Now of course our notes are not yet locked but guys we are able to pass notes from view controller view
controller.
I really don't like that this has secure nodes and it's blue.
So let's go ahead and let's fix that by first giving an explicit back button title.
So we're going to go ahead and select our navigation bar up at the top and for the Back button we'll
just type back.
OK.
And what we're going to do is we're going to go ahead and set the tent to be yellow.
OK.
And by doing that it's going to set every button that is you know coming from this to be also yellow.
So build and run let's make sure that that worked.
And that fixed our issue.
Then we're going to go ahead and move on.
OK so let's select the note.
OK good.
We've got a yellow back button with the word back that's perfect.
Very very cool stuff.
Let's think what do we need to do now.
We passed no data to our detail Visi we're displaying it there which looks awesome.
Very very cool stuff.
We can select it we can go back you know what I think this is great guys but what we're going to do
is we're going to set when we tap on lock note K dismisses and goes back.
That's great but we need to set it so that it actually updates the lock status reloads the table view
and shows our new locked cell.
OK then we're going to move on to touch I.D. and face ID.
Very cool we had to build the up first and now we're going to integrate the Touch ID framework's.
So let's go ahead let's head over to the next video where we're going to write some helper functions
and we're going to use that to update our notes cell.
All right let's head over there now.