I am trying to use the CoreSpotlight API in an application, I have a plist file on which there are several elements, for example, the name of the animal. Therefore, I need to set the title string equal to the value of this object, for example, if users search for Lion, the name of the line and, for example, its functions are displayed in the spotlight. Here is my code:
- (void)setupCoreSpotlightSearch { CSSearchableItemAttributeSet *attibuteSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(__bridge NSString *)kUTTypeImage]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"animals" withExtension:@"plist"]; NSArray *playDictionariesArray = [[NSArray alloc ] initWithContentsOfURL:url]; NSString *getNames = [NSString stringWithFormat:@"%@",playDictionariesArray]; NSLog(@"%@",getNames) ; attibuteSet.title =getNames; attibuteSet.contentDescription = @"blah blah "; CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier:@"app name" domainIdentifier:@"com.compont.appname" attributeSet:attibuteSet]; if (item) { [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * _Nullable error) { if (!error) { NSLog(@"Search item indexed"); } }]; } }
Problem getNames returns all names !!! how can I filter it when the user searches for a specific word from animals.plist Thank you.
EDIT [Image of Plist]: 
source share