使用NSPredicate按对象属性过滤 [英] Use NSPredicate to filter by object attribute
本文介绍了使用NSPredicate按对象属性过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可变的自定义对象数组。我想按对象的属性来过滤该数组,例如 myObject.attributeOne 。
I have a mutable array of custom objects. I want to filter that array by attribute of the object, for example myObject.attributeOne.
如何创建NSPredicate与
How can I create the NSPredicate to use with
[myArrayOfObjects filterUsingPredicate:<the_predicate>]
推荐答案
以这种方式使用:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"FriendStatus == 1"];
NSMutableArray *filtered = [MessageArray filteredArrayUsingPredicate:predicate];
这篇关于使用NSPredicate按对象属性过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文