华威张
华威张

Reputation: 41

how to get CSSearchableItemAttributeSet in appDelegate

NSMutableArray *searchableItems = [NSMutableArray array];

for (int i = 1; i < 100; i++) {

    CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc]initWithItemContentType:@"vvv"];

    attributeSet.title = [NSString stringWithFormat:@"warwick%d",i];
    attributeSet.contentDescription = @"warwickDescriotion";
    UIImage *image = [UIImage imageNamed:@"1"];
    attributeSet.thumbnailData = UIImagePNGRepresentation(image);

    CSCustomAttributeKey *lat = [[CSCustomAttributeKey alloc]initWithKeyName:@"lat"];
    [attributeSet setValue:@"123456789" forCustomKey:lat];

    CSSearchableItem *item = [[CSSearchableItem alloc]initWithUniqueIdentifier:[NSString stringWithFormat:@"warwick%d",i] domainIdentifier:nil attributeSet:attributeSet];

    [searchableItems addObject:item];
}

[[CSSearchableIndex defaultSearchableIndex]indexSearchableItems:searchableItems completionHandler:nil];

I have set some searchableItems with a customKey, how can I get the customKeyValue in AppDelegate?

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler

Upvotes: 4

Views: 712

Answers (1)

PGDev
PGDev

Reputation: 24341

The only thing you get in the AppDelegate continueUserActivity method is the unique identifier of the CSSearchableItem in the userInfo dictionary of userActivity and nothing else.

Upvotes: 1

Related Questions