0

I am adding all my 3D Touch actions in my app delegate but how can I update the subtitle of one of the actions throughout my app?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Nick Lasta
  • 121
  • 1
  • 8

1 Answers1

1

Take a look at this reference from Apple. The first code sample gives you what you need to modify an existing quick action with a new localizedTitle.

Here's the Objective-C code from the Apple example. In summary, you create a UIMutableApplicationShortcutItem with a mutable copy of the shortcut item you want to modify. Change the title and then replace the previous shortcut with the new one.

NSArray <UIApplicationShortcutItem *> *existingShortcutItems = [[UIApplication sharedApplication] shortcutItems];
UIApplicationShortcutItem *anExistingShortcutItem = [existingShortcutItems objectAtIndex: anIndex];
NSMutableArray <UIApplicationShortcutItem *> *updatedShortcutItems = [existingShortcutItems mutableCopy];
UIMutableApplicationShortcutItem *aMutableShortcutItem = [anExistingShortcutItem mutableCopy];
[aMutableShortcutItem setLocalizedTitle: @“New Title”];
[updatedShortcutItems replaceObjectAtIndex: anIndex withObject: aMutableShortcutItem];
[[UIApplication sharedApplication] setShortcutItems: updatedShortcutItems];
stevekohls
  • 2,214
  • 23
  • 29
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/12131735) – frasertweedale Apr 25 '16 at 02:20
  • @frasertweedale I copied the Apple sample code with some explanatory text. – stevekohls Apr 25 '16 at 02:34