Exploring Shortcuts App in iOS 12

Apple recently released the latest iOS version, iOS 12, packed with various features and updates. If you own an iOS device and your device is compatible with iOS 12 then I recommend that you update it. Although, this update brought a lot of new enhancements and performance improvements, the one thing which I really like and find myself using on a daily basis is “Shortcuts” app. Like any other app, you can download it from the App Store.

What is "Shortcuts” App?

It’s an iOS app which lets you combine a bunch of different actions into a single shortcut which you can then invoke either by tapping that shortcut or adding that shortcut to Siri by assigning it a phrase. Whenever you say that phrase to Siri, the shortcut will be invoked. There is also a “Shortcuts widget” which shows the shortcuts that you have created and you can use those shortcuts from the widget itself. You can configure in the shortcut whether it should appear in the widget or not.

What actions are available?

If you open the app, you’ll see that there are mainly 2 sections:

  1. Library: Shows all the shortcuts which have installed/created.
  2. Gallery: Shows the list of pre-defined shortcuts which you can directly install and use.

When you start creating a new shortcut, you can see a lot of actions are available to choose from and can be combined into a chain which is called one after the other. Here is a GIF showing the currently available actions:


Some of the actions that jump out to me are:

  • If-Else block (Executes an action if the given condition is true)
  • Repeat block (Executes an action certain number of times)
  • API call (You can actually call an API as a part of executing a shortcut)
  • Run Script over SSH Surprised smile

Creating a simple shortcut:

One of the shortcuts that I created and use regularly combines a series of steps which I find myself doing regularly whenever I go outside my house, like:

  1. Turn on Bluetooth
  2. Turn off Wi-Fi
  3. Turn on Mobile Data
  4. Turn on Low Power Mode

So, I defined all those steps into a single shortcut and instead of doing every action one by one, I can just use the shortcut to do it for me. Below is a screenshot showing the shortcut.

Going Outside

Remember, all you have to do is search for action which you want to do, drag and drop that action onto the shortcut’s canvas and configure it based on your needs. Also, when you use your phone, Siri will remember the actions that you are doing like setting an alarm or messaging someone on WhatsApp and you can find these actions under “Siri Suggestions” while creating a shortcut and use those directly.

Wrapping Up:

Shortcuts is a great app which can really help you in automating the tasks which you find cumbersome to do. All you have to do is find the things that you are doing regularly on your iPhone/iPad and if there is an appropriate action available for it then create a shortcut.

I hope this post gives you some idea of what the “Shortcuts” app can do. I encourage you to download the app and explore it.

Let me know about the awesome shortcuts that you create in the comments below.

PS: For the above GIF, I used the “screen recording” feature of the phone to create a video and then used a shortcut from gallery to convert that video to GIF Winking smile.

Strongly typed configuration in ASP.NET Core 2.0 using IOptions<T>

When it comes to configuration, ASP.NET Core provides various ways to read configuration like from a json file, environment variables, command line arguments etc. This is great but it gets better. ASP.NET Core allows you to have a strongly typed configuration and it is the recommended way of reading configuration.

How can you do it?

The way to do it is to have a class with similar structure as a section of your configuration.  Let’s say that you have a configuration like below in your appsettings.json file:


Note: I am using appsettings.json as an example but the configuration can come from any source.


Normally, if you want to read the value of FirstSetting in your code you'll have to access it like Configuration["MyConfigSettings:FirstSetting"] and this is okay for simple configuration but as your application grows and things get more complex this code starts to look cumbersome.

There are a couple of things which I don’t like about accessing the configuration like that but the most important thing which jumps out is that anyone can easily mistype the configuration key and then spend hours wondering why the configuration isn’t getting loaded.

This is where IOptions<T> shines. You can create a class (like below) in which the property names matches the name of the config settings and then bind a section of your configuration to that class in Startup.cs

And then in ConfigureServices method of your Startup.cs:

Now when your app starts, ASP.NET Core framework will bind the entire MyConfigSettings section to your class and will be available throughout your application via DI (Dependency Injection).

Accessing IOptions<T>:

Let’s say you want to access the value in a controller. First, you’ll need to add a reference to Microsoft.Extensions.Options and then in the constructor of your controller you can just receive a property of type IOptions<MyConfigSettings> and store it in some local field/property. The IOptions<T> exposes a property called Value which is of type T and hence contains all the properties of your class with values populated by the configuration system. So the FirstSetting can be accessed like MyConfigSettings.Value.FirstSetting. Here is the complete code for the controller:

This was a pretty simple example but even if you have a more complex type having complex properties that can also be accessed in a similar way given that your configuration values follow the same structure.


Having a strongly typed configuration system really helps in the development process as you don’t have to remember the names of the configuration keys and also saves you from making mistakes. ASP.NET Core provides a nice and easy way to handle this. I hope this post helps you in setting it up in your application.

The complete source code can be found here.


More Resources: