gpt4 book ai didi

iphone - 使用 NSPredicate 按对象属性过滤

转载 作者:行者123 更新时间:2023-12-03 19:35:31 24 4
gpt4 key购买 nike

我有一个可变的自定义对象数组。我想按对象的属性过滤该数组,例如 myObject.attributeOne

如何创建 NSPredicate 来使用

[myArrayOfObjects filterUsingPredicate:<the_predicate>]

最佳答案

这样使用:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"FriendStatus == 1"];

NSMutableArray *filtered = [MessageArray filteredArrayUsingPredicate:predicate];

关于iphone - 使用 NSPredicate 按对象属性过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3386079/

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