Hello,
I have created an NSUserActivity item using the code below. while the item gets indexed, selecting it causes my iPad mini 2 to crash. I'm not savvy enough to understand crash logs and what not, but I'm not getting any error messages as the crash happens before it returns to the app. iPad resets then Xcode complains the same way it does, when you force close the app while in debugging mode.
A few short comments:
- Indexing using CSSearchableItem does NOT cause any crashes
- In the case above, it was ONLY indexed using NSUserActivity WITHOUT CSSearchableItem
- This is a system crash and not an app crash. It happens as I click on a search ite, doesn't get anywhere close to my app before crash.
- Issue happens on iPad simulator as well.
On simulator I see the following error, between each error there is a time delay:
2015-09-15 19:10:23.071 StockSwipe[88611:3076569] Can't endBackgroundTask: no background task exists with identifier 7, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
2015-09-15 19:11:23.198 StockSwipe[88611:3076569] Can't endBackgroundTask: no background task exists with identifier 9, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
2015-09-15 19:12:23.379 StockSwipe[88611:3076569] Can't endBackgroundTask: no background task exists with identifier b, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
2015-09-15 19:12:59.608 StockSwipe[88611:3079415] Terminating since there is no system app.
System details:
HW: iPad mini 2
OS: iOS 9 GM
Code:
var nsUserActivityArray:[NSUserActivity] = []
@available(iOS 9.0, *)
func createNSUserActivity(title: String, companyName: String, contentDescription: String, image: NSData?, uniqueIdentifier: String, domainIdentifier: String) {
let attributeSet:CSSearchableItemAttributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeImage as String)
attributeSet.contentDescription = contentDescription
let activity = NSUserActivity(activityType: domainIdentifier)
activity.title = title
activity.keywords = NSSet(array: [title, companyName, contentDescription, "Stocks", "Markets"]) as! Set<String>
activity.userInfo = ["symbol": title, "companyName": companyName, "searchDescription": contentDescription]
activity.contentAttributeSet = attributeSet
activity.requiredUserInfoKeys = NSSet(array: ["title", "userInfo", "contentAttributeSet", "eligibleForSearch", "eligibleForPublicIndexing"]) as! Set<String>
activity.eligibleForSearch = true
activity.eligibleForPublicIndexing = true
nsUserActivityArray.append(activity)
activity.becomeCurrent()
print("NSUserActivity created")
}