Created
July 18, 2013 12:31
-
-
Save letsspeak/6028927 to your computer and use it in GitHub Desktop.
search files in paticular directory (not sub directories)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString* path=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; | |
path=[path stringByAppendingPathComponent:@"Downloads"]; | |
NSString *filename = nil; | |
NSDictionary *attrs = nil; | |
NSDirectoryEnumerator* dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:path]; | |
[dirEnum skipDescendants]; | |
while (filename = [dirEnum nextObject]) { | |
NSUInteger level = [dirEnum level]; | |
if (level == 1) { | |
attrs = [dirEnum fileAttributes]; | |
NSLog(@"%d:%@: %@", [dirEnum level], [attrs objectForKey:NSFileType], filename); | |
} else { | |
[dirEnum skipDescendants]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment