Skip to content

Instantly share code, notes, and snippets.

@fallenleavesguy
Last active October 7, 2017 18:13
Show Gist options
  • Save fallenleavesguy/4c578c318a1fae9a88bf206b6ae7d27d to your computer and use it in GitHub Desktop.
Save fallenleavesguy/4c578c318a1fae9a88bf206b6ae7d27d to your computer and use it in GitHub Desktop.
recursive search jpg file in home.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
NSLog(@"beginning search...");
@autoreleasepool
{
NSFileManager *manager = [NSFileManager defaultManager];
NSString *home = [@"~" stringByExpandingTildeInPath];
NSMutableArray *files;
files = [NSMutableArray arrayWithCapacity:42];
for (NSString *filename in [manager enumeratorAtPath:home])
{
if ([[filename pathExtension] isEqualTo:@"jpg"])
{
[files addObject:filename];
}
}
for (NSString *filename in files)
{
NSLog(@"%@", filename);
}
}
NSLog(@"ending search...");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment