NSArray - filteredArrayUsingPredicate

来源:互联网 发布:广州java培训哪家好 编辑:程序博客网 时间:2024/06/05 23:45
NSArray - filteredArrayUsingPredicate:
Evaluates a given predicate against each object in the receiving array and returns a new array containing the objects for which the predicate returns true.

Declaration
SWIFT
func filteredArrayUsingPredicate(_ predicate: NSPredicate) -> [AnyObject]
OBJECTIVE-C
- (NSArray<ObjectType> *)filteredArrayUsingPredicate:(NSPredicate *)predicate

Parameters
predicate
The predicate against which to evaluate the receiving array’s elements.
Return Value
A new array containing the objects in the receiving array for which predicate returns true.

Discussion
For more details, see Predicate Programming Guide.

Availability
Available in iOS 3.0 and later.


例子:
[self.products filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"weight > 10"]];

0 0
原创粉丝点击