INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions) crashes in iOS 13 Beta. Xcode 11 beta

Viewed 327

My code is pretty straight forward. I am not sure what is the issue and I am not able to find a solution.

var suggestions = [INShortcut]()

for component in components
{
    if let userActivity = UserActivityGenerator.getUserActivity(component: component)
    {
        let shortCut = INShortcut.init(userActivity: userActivity)
        suggestions.append(shortCut)
    }
}

INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions)

The app crashes in setShortcutSuggestions.

It works fine in iOS 12 with same Xcode 11 Beta.

1 Answers

Execute the function in the main queue.

   DispatchQueue.main.async {
        INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions)
    }
Related