NSUserActivity在OSX上没有被索引

11

我正在尝试将我的活动添加到OSX 10.11的Spotlight搜索结果中。但是尝试了很多次后,我无法通过关键字搜索或标题搜索在Spotlight搜索结果中找到它。

{
    self.userActivity = [[NSUserActivity alloc] initWithActivityType:@"Reverse DNS keyword"];

    self.userActivity.title = @"Some title";
    self.userActivity.keywords = [NSSet setWithArray: @[@"Some keywords"]];
    self.userActivity.eligibleForSearch = YES;
    self.userActivity.eligibleForHandoff = YES;
    self.userActivity.eligibleForPublicIndexing = YES;
    self.userActivity.userInfo = @{@"name" : @"Some name"};
    self.userActivity.delegate = self;
    self.userActivity.requiredUserInfoKeys =[NSSet setWithArray: @[@"name"]];
    self.userActivity.needsSave = YES;

    [self.userActivity becomeCurrent];

    NSApp.userActivity = self.userActivity;
}

- (void)userActivityWillSave:(NSUserActivity *)userActivity
{
     userActivity.userInfo = @{@"name" : @"Some name"};
}

同时,我已经使用NSUserActivityTypes数组和initWithActivityType:参数中的项更新了Info.plist。

我还注意到在控制台中有时会出现以下消息:

16/09/2016 13:14:49.731 Caching encoded userInfo to use until we are marked dirty again (UAUserActivity.m #1567)
16/09/2016 13:14:49.731 Returning cached encoded userInfo (UAUserActivity.m #1508)
1个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
1

经过大量搜索,最终我在TN2416中找到了我的问题的答案:

**Are these new Search APIs available on OS X?**

CoreSpotlight and the search functionality of NSUserActivity are not supported on OS X.  However, web search results may be shown on OS X.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,