2016-03-29 6 views
3
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]; 

ich einige searchableItems mit einem customKey festgelegt haben, wie kann ich die customKeyValue in AppDelegate bekommen?wie man CSSearchableItemAttributeSet in AppDelegate

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

Antwort

1

Das einzige, was Sie in der AppDelegatecontinueUserActivity Methode erhalten, ist die eindeutige Kennung des CSSearchableItem im userInfo Wörterbuch von userActivity und nichts anderes.