Shortcuts App iOS – How to Get Index of Selected List Item

iosshortcuts-app

In an iOS shortcut I can ask the user to select an item from a list, but how do I access the selected index?

I need that in order to get at the selected object in the case where I’ve already converted the objects into more presentable text for the action sheet.

Update:

What I really wanted was to customise the user-facing string representation of an item.

Best Answer

Based on the comments, this Apple Support site held the answer. Use "Set Name" to get the value:

To set a custom name for an item that an action outputs, such as an image in the Get Latest Photos action, place a Set Name action in between the Get Latest Photos action and the Choose from List action. When the shortcut is run, the custom name (rather than the default name, such as “IMG_0365”) is applied to the image output from the Get Latest Photos action.

If you use the Choose from List action with the Dictionary action, all of the keys in the dictionary are displayed when you tap “Add new item.” For each key you select, such as Number, Boolean, or Array, the corresponding values are passed as output.

Related Question