Mac|Life

Help yourself to avoid these pitfalls

Things to look out for if the shortcut you’ve painstakin­gly put together isn’t working

-

Getting up to full speed with the Shortcuts app takes time, and you’ll inevitably make a few mistakes along the way. Having to troublesho­ot your efforts doesn’t mean you’ve failed — with years of experience, even profession­al programmer­s do this.

Take a step back to reassess whether the steps you identified for solving your problem are complete and in the correct order. If so, follow the flow of control and informatio­n through your shortcut to check it matches your intended logic.

Still haven’t spotted a clear flaw in your design? Stepping through your workflow for real may help pinpoint the mistake. You can use the Show Alert action and a variable to inspect a result to verify it’s what you expect.

Tracing your steps

If you sense where things are failing, add Show Alert just before and after that point to check the action’s input and output. In Show Alert’s body, use variables to check the values.

Not all data that’s processed by an action is passed to it from the previous one. Some come from variables you’ve manipulate­d with the Set Variable, Add to Variable and Get Variable actions, or magic variables that retrieve the result of a much earlier action — check you’ve selected the right one. You may end up tracing further back than you thought.

Check your logic

A common construct you’ll see in example shortcuts (such as ‘Read later’ in the Gallery tab) is checking whether an action receives one item or several. Check you’ve addressed that — you may need to loop through a collection of data using the ‘Repeat with Each’ action, or choose the specific attribute to process, as you did earlier to get directions home.

On the previous page, you saw that you need to explicitly save the results of an image–processing shortcut to your photo library to keep the result. This is necessary for files too. For example, if using Make Archive or Extract Archive, you probably want to use Save File too.

Still stuck? Revisit the Gallery tab in Shortcuts for new examples showcased by Apple. As more people use the app, you may discover one of them has solved your problem — if not exactly, closely enough that you can adapt it.

To the right, we’ve identified various third–party resources where you’ll find extra examples, beyond Shortcuts’ own gallery.

 ??  ?? To select a magic variable, tap the wand button, then the token for the relevant action’s output.
To select a magic variable, tap the wand button, then the token for the relevant action’s output.

Newspapers in English

Newspapers from Australia