所以我正在尝试在应用程序委托中捐赠多个快捷方式(如 20 种类型的活动)......如果我在特定的视图控制器中捐赠它很奇怪,但是如果我在应用程序委托中创建一个 for 循环它不起作用......这是代码:
activity = NSUserActivity(activityType: activityType)
activity?.title = activityTitle
if #available(iOS 12.0, *) {
activity?.suggestedInvocationPhrase = suggestedPhrase
activity?.isEligibleForPrediction = true
activity?.persistentIdentifier = NSUserActivityPersistentIdentifier(activityType)
}
activity?.isEligibleForSearch = true
//self.activities.append(activity!)
if #available(iOS 12.0, *) {
NSUserActivity.deleteSavedUserActivities(withPersistentIdentifiers: [activityType], completionHandler: {[weak self] in
self?.activity?.becomeCurrent()
})
}