Created
April 4, 2013 11:49
-
-
Save odrobnik/5309752 to your computer and use it in GitHub Desktop.
Pictures at URL
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
- (NSArray *)_picturesInDirectoryAtURL:(NSURL *)URL | |
{ | |
NSMutableArray *tmpArray = [NSMutableArray array]; | |
NSArray *keys = [NSArray arrayWithObjects: | |
NSURLIsDirectoryKey, NSURLIsPackageKey, NSURLLocalizedNameKey, nil]; | |
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] | |
enumeratorAtURL:URL | |
includingPropertiesForKeys:keys | |
options:(NSDirectoryEnumerationSkipsPackageDescendants | NSDirectoryEnumerationSkipsHiddenFiles) | |
errorHandler:^(NSURL *url, NSError *error) { | |
NSLog(@"%@", [error localizedDescription]); | |
// Handle the error. | |
// Return YES if the enumeration should continue after the error. | |
return NO; | |
}]; | |
// enumerator goes into depth too! | |
for (NSURL *url in enumerator) | |
{ | |
NSNumber *isDirectory = nil; | |
[url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL]; | |
if (![isDirectory boolValue]) | |
{ | |
if ([[url path] isImageFileName]) | |
{ | |
ModelPicture *picture = [[ModelPicture alloc] initWithURL:url]; | |
[tmpArray addObject:picture]; | |
} | |
} | |
} | |
return tmpArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment