0
我已成功(有點)在我的iPhone應用程序中實現聚光燈索引,但某些搜索字符串似乎無法搜索。ios 9核心聚光燈搜索不適用於某些字符串CSSearchableItemAttributeSet
我創建每個CSSearchableItemAttributeSet作爲類型kUTTypeText,我設置顯示名稱,標題爲「D0010」。我還將關鍵字設置爲包含「D0010」。 (有幾百個數字,例如D0011,D0012 ......)
該應用程序完成索引時沒有錯誤。
當我進入焦點搜索並鍵入「D0」時,我得到三個左右的結果,因爲我繼續鍵入「D001」,我沒有得到任何結果。
有趣的是,如果我輸入「0010」,我會得到確切的結果!
有沒有人有任何想法是怎麼回事?
部分客觀C代碼如下。
attributeSet.displayName = [[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]];
attributeSet.title = [[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]];
//Sounds similar to displayName but is not displayed to user
attributeSet.contentDescription = [[NSString alloc] initWithFormat:@"%@", [dataflow flowDescription]];
attributeSet.keywords = @[[[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]],[[NSString alloc] initWithFormat:@"D%@", [dataflow flowNumber]],[dataflow flowCounter], attributeSet.displayName, attributeSet.contentDescription,[dataflow flowNumber],[dataflow flowCounter] ];
CSSearchableItem *item1 = [[CSSearchableItem alloc] initWithUniqueIdentifier:[[NSString alloc] initWithFormat:@"DTC_%@", [dataflow flowNumber]] domainIdentifier:@"com.utiligroup" attributeSet:attributeSet];
........
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:[self.spotlightsearch copy]
completionHandler: ^(NSError * __nullable error) {
if (error != nil){
NSLog(@"Error");
}
else {
NSLog(@"dataflows added ");