the where statement is like using a predicate in cocoa/cocoa touch. here is an example, where I have an array of image file names from a directory and I am looking for the base file name. The indexesOfObjectsWithOptions: method returns a set of Indices that pass the specific test. NSEnumerationConcurrent utilizes a concurrent queue to take advantage of multiple cores, if present.
NSIndexSet *indexSet=[allImageURLs indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
BOOL match=NO;
NSRange twoXRange=[((NSURL *)obj).absoluteString rangeOfString:@"@2x"];
NSRange iPhoneRange=[((NSURL *)obj).absoluteString rangeOfString:@"~ipad"];
if (twoXRange.location==NSNotFound && iPhoneRange.location==NSNotFound) {
match=YES;
}
return match;
}];
self.imageURLs=[allImageURLs objectsAtIndexes: indexSet];
for your particular case I would do the following:
NSIndexSet *theSet=[coursesinfo indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
BOOL match=NO;
if( obj.finalGrade<100 ){
match=YES;
}
return match;
}];
NSArray *courses=[coursesinfo objectsAtIndexes: theSet];
Good luck!
t
indexOfObjectPassingTest, along with several different sorting options.