Everyone will come back to class and Johnny be here with slopes dot com.
We're continuing working on our shortcut app and in the last lesson we got all of our UI set up and
it's looking fantastic but when we first touch on our app nothing is happening.
So we're going to remedy that in this lesson.
All right.
So let's take a look at the apple documentation here.
Pull it over here.
If you just do a search for UI application shortcut items should be one of the first ones.
Go ahead and I'll just use my publication short cut item then.
Yeah right here developer dot apple dot com documentation that will take you right to here.
And so let's go and just read a little bit.
It's always good to jump into the official Apple documentation when you are learning something new.
All right says that the UI application shortcut items specifies the static homescreen quick actions
for the app.
This key contains an array of dictionaries.
So we're going to be working in our Infocom P list and we're going to create an array of called UI application
shortcut items and inside of it we are going to see here it says that we are going to have an array
of dictionaries.
The number of quick actions shown for your app on the home screen when the user presses your home screen
icon on a device that supports 3D touch is determined by the system.
All right so we have our array called UI application shortcut items and inside of it is a number of
dictionaries.
Now you can have up to four quick actions show wins when you press down on your app icon.
All right.
And so keep that in mind that you can only have four.
And there's actually something called static and dynamic shortcuts.
We're only going to be covering static ones in this Target topic.
Well maybe maybe we'll get to dynamic ones we'll see.
But the static ones are defined in your list and that's where we're going to be working.
All right so there are some keys that we need for a quick action.
All right.
So the first type is are the first key is right here UI application a short cut item type.
And this is a required string delivered to your app when the user invokes the corresponding quick action.
So basically this is just an identifier for your quick action that we can do a check in our app delegate
file to be able to say if it was this type then do this if it was this one then do that.
All right so it's just an identifier.
Then we have a UI application shortcut item and title.
So our shortcut has a title and that's also required.
And then we have some optional ones here.
We have an item subtitle so that's optional.
It'll be displayed below the main title The main item title.
Then we have a UI application shortcut item icon type so optionally we can have our our quick actions
have an icon next to it and it can either be so if you use this one the item icon type then it's an
optional string specifying the type of an icon from the system provided library.
And if you click here see the application shortcut icon type then that will take you over here and this
will show you all of the system icon types that are available to you such as compose which will be view
this icon right here or play or see here what do we got prohibit.
Yes so you've got you've got a fair number of system icons that are available to you here.
However if you want to have your own icons like we are going to do then you can use UI applications
shortcut item icon file and this is an optional string specifying an icon image to use from the apps
bundle or the name of an image in an asset catalog.
All right and if you remember in our project we imported our assets for mountain short ocean short and
space short.
All right and so these are the icons for our short cut items.
And if you want to make your own like it says here I should be square a single color and 35 by 35 points.
Then came the Gottesman Photoshop template files.
However I like to use sketch.
And here is actually the sketch file that I use to make the assets for for this target topic.
We've got our our view controller images here and then down here we have our shortcut icons here and
you can see that each art board here is 35 by 35.
And sketches super super nice.
All you've got to do is look at your art boards that you want to export and say export at 1 2 and 3
x and anyways so yeah you can use whatever you want Photoshop.
I got to do is just make sure that your your your art board is or your layer is 40 or 35 by 35 points
and then you need to export that at 2 and 3 x so 70 and whatever three times 35 is now the last optional.
Key here is a UI application shortcut item user info.
All right so this is an optional app.
B find a dictionary one use for this dictionary provide perversion information.
So we're so i to be working with this at all but that's just if you want to pass additional information
with your quick action.
All right so these are the ones that we are going to need to implement in our food list.
Let's go ahead and do that.
All right let's go to our food list and we are going to need to create a new key and the one that we
want is not going to be provided in our auto.
So I'm going to jump back here to our safari our documentation and right here is what we want you application
shortcut items are going to copy this Anjum pack into index code and paste it right here.
There we go.
And we're going to change the type 2 array because we we're going to have an array of dictionaries and
then each dictionary holds the information for our quick action and inside of that dictionary is all
of this information right here.
And you can see here we have an example of what that's going to look like.
So here's the array.
Here's our first item so this is right here contains one quick action and then right here contains the
second to quick action.
And we have the icon file the title the type and the user info.
All right so let's go ahead and add those.
Let's start with the shortcut.
Item type I'm going to copy that right here.
And then we're going to jump over here and we're going to have to create a new item.
And so this is item 0 and this is going to be a dictionary.
And then we can put the arrow down again and we're going to add again and this time we can paste.
Well I'll just show you what we copied if you missed it.
Is this application shortcut item type.
It's going to copy that again and right here to paste and then I'm going to just expand this right here
the property list.
All right so this is a string.
This is our identifier and it's common practice for this to be your bundle identifier followed by some
sort of identifier.
OK.
So I'm just going to copy what we have here for the product bundle identifier.
Copy that and paste it and then I'm going to append that.
And this is our first one.
So it's going to be Mt..
Just mountains mountains.
OK.
So there we have our first key for our quick action.
Next up I'm just swapping back to Safari.
Here is our shortcut item title right so we're going to copy the item title which is also required.
We're going to create a new key value pair here.
So we're going to select the plus and I'm going to paste here your application the shortcut item title.
This is another string and we can just same mountains.
And this is the actual string that you see when you press and hold.
All right.
Next up we have an application Shurkin item subtitle and we're not actually going to use the subtype
Well you know I'm going to use it once just to show you what it looks like and then I'll probably get
rid of it and I'm going to say.
So majestic.
There we go.
All right next up we have the item I icon type and I told you that we're going to use the custom ones
but I'm going to start out or start out putting this in just so you can see what it looks like.
So when I paste it and then the string that you need to use I'm coming back toward documentation is
this I'm going to copy this application shortcut icon type.
I'm going to paste it followed by any of these.
Let's go ahead and do and see here love case.
So you have you application shortcut.
I can type in followed by the hoops not love love followed by the enumerator type.
OK.
Any of these cases but it's a capital letter of any of these.
There we go.
And then after I show you we'll come back here and switch.
Swap it out for the custom one that we made.
All right so what do we have next.
Shortcut icon type icon file and that's actually since we're not going to be doing the shortcut.
Item user info that would just be another dictionary that you would add.
OK.
All right so you know what that's actually all we need to do to be able to just see it.
OK so let's go ahead and run this.
All right going to come back out here and then we're going to touch you.
There we go.
Mountains so majestic and we have our icon.
All right.
Not bad not bad.
All right so now that I showed you the icon type I'm going to get rid of it.
So I jump back into safari and we want the shortcut item icon file.
I want to copy that come back here pasted there.
And the one that we want is what did we name it.
It's it's called Mountain short.
OK.
It's right here.
The shortcut item I file mountain short There you go.
And how do we get this new item get to that.
All right so let's go ahead and run this again see how that looks.
All right go back to home and force touch.
There we go.
Now we got our mountain custom icon right there.
Very nice.
All right so let's go ahead and let's add our other two quick actions real quick so I'm going to click
here and I'm going to add air.
Our second item which is also a dictionary I want to put the arrow down.
Then we're going to press the plus button again and we are just going to repeat OK plus And again this
one is going back to Safari.
Just going through them again we have our item type
and it stream is going to open up our first dictionary.
Well I'm just going to copy this whole string pasted here and instead of mountains this is going to
be space.
And let's hear what's next.
The application shortcut title King plus and paste and space.
There you go.
And plus for our next key which is we'll skip the subtitle on this one and just come down here to item
like on file.
When I copy that and drop it in here and paste it and this one the icon file is space short.
Now we go.
And that covers it for this quick action enclose item 1 and do another plus change the type to dictionary.
Drop the arrow down and press plus again and then just copy from our previous dictionary here.
Copy the icon item type.
Paste it I'm sorry the shortcut item type.
I'm going to copy from right here as well and paste here and this identifier is going to be ocean.
There we go.
And then click on the plus to add a new key.
Click on or will come up here and copy this one's key here and then paste it here and add a title.
And this one is ocean.
There we go.
And then we're going to press the plus button again and this time will skip the subtitle and select
the icon file.
Copy that.
Copy that key and paste it here.
And this one is called Ocean short.
All right there we go.
Let's run this and make sure we're going all right we're going to go to the home and forced touch.
And there we go all three of them mountains space and ocean.
And when to get rid of this subtitle on the mountains one here.
That was item zero subtitle.
I'm just going to click on the minus sign to get rid of it.
Let's read that one more time.
All right going home and force touch.
There we go.
Mountain space and ocean.
Pretty cool.
So right now if we click on one of them all it does is take us to the same view.
It just opens it and yes I'm not doing not doing too much.
Looks cool but not doing too much.
And the next lesson we're going to start coding up in the delegate so that we can receive messages for
when someone actually clicks on that and take the recording necessary actions are.
So see you then.