过滤 NSArrayController 时出现问题

发布于 2024-10-11 22:08:38 字数 307 浏览 5 评论 0原文

我在过滤 NSArrayController 时遇到问题。 Content Array 绑定到保存 NSDictionaries 的 NSMutableArray。我想过滤所有“name”键等于“a”的 NSDictionaries。 当我的应用程序启动时,我运行这两行,但没有任何内容被过滤。

NSPredicate *filter = [NSPredicate predicateWithFormat: @"name like %@", @"a"];

[arrayController setFilterPredicate: filter];

I have problem filtering an NSArrayController. Content Array is bound to an NSMutableArray holding NSDictionaries. I want to filter all NSDictionaries whose "name" key equals "a".
I run these two lines when my app launches but nothing gets filtered.

NSPredicate *filter = [NSPredicate predicateWithFormat: @"name like %@", @"a"];

[arrayController setFilterPredicate: filter];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软甜啾 2024-10-18 22:08:38
NSPredicate *filter = [NSPredicate predicateWithFormat: @"name=%@", @"a"];

[arrayController setFilterPredicate: filter];
NSPredicate *filter = [NSPredicate predicateWithFormat: @"name=%@", @"a"];

[arrayController setFilterPredicate: filter];
薄荷港 2024-10-18 22:08:38
NSPredicate *filter = [NSPredicate predicateWithFormat:@"(name contains[cd] $a)"];
[arrayController setFilterPredicate: filter];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"(name contains[cd] $a)"];
[arrayController setFilterPredicate: filter];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文