Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:52
Show Gist options
  • Save priore/7163607 to your computer and use it in GitHub Desktop.
Save priore/7163607 to your computer and use it in GitHub Desktop.
Get file list with NSPredicate
// get file list with NSPredicate
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundlePath error:nil];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self like '*.jpeg'"];
NSArray *fileNames = [[dirContents filteredArrayUsingPredicate:fltr] retain];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment