1

I'm computing a NSUserActivity for when I view a specific screen in my app. (Doesn't matter what, imagine a Location)

I set a lot of information about this activity/location using the contentAttributeSet.

When I visit this screen over and over, I set the viewController's userActivity property to this derived activity, and also call becomeCurrent() on it.

Eventually Siri will suggest that shortcut in Spotlight. As expected and desired. I tap on that, it launches my app and calls:

func application( _ application: UIApplication,
                      continue userActivity: NSUserActivity,
                      restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool

however, the .contentAttributeSet property will be nil.

Why? Have I not understood something here? I guess any data I need to access later should be in the userInfo dictionary? That works (as long as I don't set webpageURL)

horseshoe7
  • 2,745
  • 2
  • 35
  • 49
  • I think the ContentAttributedSet is just a setter to set these attributes to spotlight or whatever. https://developer.apple.com/documentation/foundation/nsuseractivity/1616398-contentattributeset. I would suggest to store your data localy with an identifier and set this identifer to your Item with the attributeSet and then grab the identifier from the userActivity: let identifier = activity.userInfo?[CSSearchableItemActivityIdentifier] as? String – Klinki Jan 31 '19 at 17:30

0 Answers0