I want to index multiple NSUserActivities
of same type. The code for the same is given below:
-(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];
}
From the above code, NSUserActivities for name1, name2, name3 and name4
must be created. But what I am getting is, the NSUseractivity are being overridden i.e., only name4
is getting indexed.
What is missing in the code?