Everyone will come back.
Johnny be here with soaps that come and in the last lesson we got are pretty much where we wanted for
this section.
We have it giving us the quick action shortcuts for our three controllers.
But we want to do we want to explore a little bit more.
And let's check out our main story board.
Right now we're working with a navigation controller.
What if we instead had these three in a tab our view controller.
So let's go ahead and try that out.
So we're going to go ahead and actually you know what let's go ahead.
I would recommend that you do this so that you can swap back and forth between these types between the
navigation controller and the tab bar View Controller.
I'm going to create a new branch.
OK.
So you can open up terminal and I'm going to CD into our project CD CD desktop and then what do we call
this shortcut.
There we go.
I'm going to say get Brash's to see what Branch I'm on.
I'm on a branch called Tab which was actually the one that I created to start working on this.
So I already created the branch but just to show you how to do that again when you say get checked out.
That should be handling it called this tab.
OK.
All right.
So if you've already gone through our other courses and you know how to follow along with this then
I would recommend creating a new branch if you haven't done this.
I'm not going to go deep into get right now.
So if you want to have a separate copy go ahead and just create a copy of your project folder and have
one be for the navigation controller and one for the tab bar.
You can do all right.
So right now though I have a separate branch for this one called tapetum.
All right and what I'm going to do is I'm going to delete the navigation View Controller.
I'm going to delete the segues between each of the use and then I'm going to just organize this a little
bit differently so that we have it like this.
And then what we can do is pretty cool.
We're just going to select the controllers so the mountain zushi and holding Shift to select the space
AVC and shift still to select the ocean visi.
And then we're going to go to editor and embed in a tab bar controller and there we go.
Now we've got these all selected and inside of the tab bar.
There you go.
Very nice.
We might need to adjust the order a little bit.
Let's go ahead and run this and see what order they came out in and nothing's happening because we forgot
to set the initial controller.
So with the Tabar controller selected We're going to go here to our attributes inspector and set the
initial controller to yes and let's try that again.
All right here we go.
So the first one is mountain's second one in space and the last one is ocean.
Just like we wanted if yours didn't happen to come out in the correct order then you can just click
and drag right here and kind of reorder those.
OK.
So just to reorder them and get it to the order that we had before which is mountain space ocean and
going to run this again make sure that I didn't mess up my order mountains space ocean.
Very good.
All right so let's go ahead and do a little bit of work here.
We're if you can change how these appear here are going to zoom in a little bit.
So here you just see item item item.
So it's going put some info here.
So you do that by clicking on the tab bar info for the individual visi.
So here and let's go ahead and give it a selected image which is Mt. short.
And the title is mountains and then the image here is also mountains short.
So Knodell say mountains and mountains here and have the image as well as over here.
There you go.
Let's go to the next one for space.
Select the item here and we're going to select these set these selected image to space short and set
the title to space and the image to space short.
There we go.
OK good.
And lastly for the ocean select the item and set the selected image to ocean short the title to the
ocean and the image to ocean shore as well.
All right let's run that one more time.
All right there we go.
Mountains space and ocean.
Oh yes.
Very nice.
I think I'd definitely prefer our tab bar.
Wii U controller better than the navigation control I think this just looks nicer.
I like it.
All right cool.
So now let's go into our app delegate and work on our quick actions.
All right so let's see here.
This time our route to view controller is not a navigation controller so let's change this right off
the bat.
It is a UI tab bar controller.
And you know what we don't actually need to have this array of VCs because it just kind of different
how it works.
We are going to set the selected index on our tab bar controller and then it instantiates it on its
own.
So we don't need these.
So we can delete this entire section and they did finish launching with options and we can delete our
VCs array variable and we can get rid of this Nav..
Vc the the section where it says set view controls and in ways we still need the variable navvy's VC.
All right and then right here we can get rid of this pop to view controller.
And so this is for space.
And so the tab bars it goes in the same kind of 0 counting so 0 1 and 2 for each tab.
So for space we want to navigate to we want to say now VCDs set or selected the selected index is equal
to one.
So that's the second controller.
And then for here we want to say Nav. we see that selected index is equal to two.
And then for the default which is Mountains which is zero for the tab we say have the seed that selected
indexes to zero Ambiga.
So let's go ahead and try that out.
All right we're going to go home 3D touch ocean.
Oh yeah.
Three touch Space Madness and lastly three touch mountains there you go.
All right.
And that is working perfectly.
Very good.
All right.
And that's it.
So our Tabar controller works very nice with our quick actions as well as on the version with the nav
navigation controller.
And the last thing that I want to show you guys before we sign off and finish up with this target topic
is early on I mentioned how there's a difference between static and dynamic shortcut items.
And so here in our list we have defined three static shortcut items.
They are static because they are built on build time dynamic Schork items.
Those are done at runtime when we actually run the code where they are declared.
So we're in do is just to give you a little bit more knowledge about this.
We're going to create a dynamic shortcut item and we're going to replace our third item our ocean shortcut
with a dynamic one.
OK.
And we're going to do that over here in our delegate as well.
So here we are going to declare it we are going to say let ocean short cut.
This is going to be a dynamic short cuts that are going to say you I mutable application shortcut item
and says an item that specifies a configurable user initiated action for your app.
OK.
There we go.
And we need to initialize it and we want this right here with all of the information and the type where
we're going to do is we are going to this is remember our string identifier and our other ones we use
the bundle doesn't mean the identifier to get it so let's do the same thing here.
So I'm going to make a string and we're going to do some string interpolation and we are going to access
our bundle identifier by saying bundle that mean that bundle identifier can.
And then we are going to say Dot ocean just like we had before.
The local ice title is also a string and say Ocean local I subtitled what I'm going to use.
So we're going to Pessin nail the icon.
So this is a little bit trickier.
We're going to say UI application and then if you just type in icon should come up and we want the UI
application shortcut icon not the type.
And we're going to say that in that template image name which is a string and then we can just Pessin
to it the name of our I call it that we want which is ocean short and then our user info dictionary
we're not using search just past and there as well.
All right so now we have created our dynamic ocean shortcut and we have a warning here to tell me about
my string describing that's fine.
All right so let's just say string describing and fix it.
All right.
There we go.
And then this warning is just because we haven't used it yet which is fine.
So now we're going to add it to our application shortcuts.
We just say application that shortcut iTunes is equal to.
And then we add the shortcut ocean shortcut.
Remember I said that you can have at most for displaying shortcut quick actions and they all.
And it gives priority to the static ones.
OK.
So if you had say three static shortcuts and then two dynamic shortcuts you're only going to see the
first three static Plus one of the dynamic ones right.
So keep that in mind.
So if I ran this we would see four we would see the three static ones and then and then we have we would
have an extra duplicate ocean shortcut.
So go and do that just to just to see it and go in and go home and force click and there you see that
we have two ocean ones.
All right very nice.
This is the static one.
And then this is the other.
This is the dynamic one that we created.
We don't need to them so let's go ahead and remove our third static shortcut item and run that again
and then go home.
And let's just make sure everything is still working as expected.
Click on ocean we go to ocean click on space and we go to space and could go on iTunes and we go to
the mountains and very nice.
All righty then ladies and gentlemen that finishes up our target topic on quick actions and 3D touch.
And so we went through quite a bit.
We talked about how to create static UI applications for items inside our up.
We went over each of the keys and which ones are required which ones are optional.
How to Create your custom icons if you want.
Using sketch or Photoshop or something remember the you need your 35 by 35 points and exported at 1
2 and 3 hex.
Or you can use the system icons at your disposal and once you have those showing up on your app icon
then you need to call the delegate function perform action for a shortcut item and then you can do a
switch statement or you can do a bunch of if else is if you want and then just handle the shortcut item.
Usually that involves navigating to one of your navigating to the specific view controller.
And we worked on a couple of different scenarios there using one with a navigation controller.
And then the one that we just did with the tab bar controller and I must say that I really like the
tempo controller quite a bit.
I think it looks good.
All right so my challenge for you all is to on both the Tabar controller and the navigation controller
versions add a fourth view controller and give it some sort of image or just a label to denote that
it's the fourth one.
Add a fourth.
Quick action shortcut and navigate and make it so that you can navigate to it as well.
All right so you should be pretty straightforward but this will help you go out on your own and reinforce
the things that we that we just learned.
All right.
So go ahead and do that and show off your work in the dischord chat channel.
I hope you enjoyed this target topic on short cuts and quick actions and I'll see you guys around.