gpt4 book ai didi

ios - 使用 NSUserActivity 使应用事件和状态可搜索

转载 作者:技术小花猫 更新时间:2023-10-29 10:43:55 54 4
gpt4 key购买 nike

以下是我试图实现的代码,使应用程序事件和状态可搜索但无法在 iOS 搜索中显示

NSUserActivity *userActivity = [[NSUserActivity alloc]initWithActivityType:@"com.mycompany.activity-type"];

userActivity.title = @"Hello world from in app search";
userActivity.keywords = [NSSet setWithArray:@[@"Hello",@"Welcome", @"search"]];
userActivity.userInfo = @{@"id":@"com.example.state"};

userActivity.eligibleForSearch = YES;
[userActivity becomeCurrent];

Link让我的问题更清楚。

最佳答案

来自 Apple 论坛:

One thing that has bitten a few people (myself included) is that the activity must not be deallocated. If your code is only working with NSUserActivities (i.e. not using CoreSpotlight in addition) then make sure your activities aren't being deallocated immediately.
In my case, I had code that was allocating the NSUA, setting some properties on it, calling becomeCurrent, but then the object would go out of scope and deallocated. If you're doing this, try tossing the activity into a strong property to see if you can then see the results when you search.

https://forums.developer.apple.com/message/13640#13640

关于ios - 使用 NSUserActivity 使应用事件和状态可搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30836398/

54 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com