我想索引多个NSUserActivities
相同类型的。下面给出了相同的代码:
-(void)createActivityForEachCity:(NSNotification *)notification
{
NSArray *nameList = @[@"name1",@"name2",@"name3",@"name4"];
if (nameList)
{
for (NSString *name in nameList)
{
[self createIndexActivityForName:name];
}
}
}
-(void)createIndexActivityForName:(NSString*)name
{
NSUserActivity *activity = [[NSUserActivity alloc]initWithActivityType:@"spotlightsearchactivity"];
NSDictionary *activityUserInfo = @{@"name":name};
activity.userInfo = activityUserInfo;
activity.title = [NSString stringWithFormat:@"You Searched for %@",name];
activity.eligibleForHandoff = NO;
activity.eligibleForSearch = YES;
activity.eligibleForPublicIndexing = YES;
self.userActivity = activity;
[activity becomeCurrent];
}
从上面的代码中,name1, name2, name3 and name4
必须创建 NSUserActivities 。但我得到的是,NSUseractivity 被覆盖,即,只有name4
被索引。
代码中缺少什么?