使用起來很是簡單。
web
假設有一個數組裏保存的都是對象,這些對象都有「name」和「 age」屬性。數組
如今要把全部姓「張」的而且年齡是30歲如下的人的資料都提取出來spa
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] '張' AND age < 30"]; NSArray *userInfoArray = [userListArray filteredArrayUsingPredicate:predicate];
userInfoArray裏保存的就是你要的內容。code