Use the NSPredicate attribute to filter by object

I have a mutable array of custom objects. I want to filter this array by an attribute of an object, for example myObject.attributeOne.

How to create an NSPredicate for use with

[myArrayOfObjects filterUsingPredicate:<the_predicate>]
+3
source share
1 answer

Use it as follows:

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

NSMutableArray *filtered = [MessageArray filteredArrayUsingPredicate:predicate];
+7
source

Source: https://habr.com/ru/post/1757620/


All Articles