Apr
10
Day 41: createDirectoryIfNecessary:
Another shorthand (this time on NSFileManager) that’ll explain itself:
- (BOOL)createDirectoryIfNecessary:(NSString *)directory
{
BOOL isDir = NO;
if ([self fileExistsAtPath:directory isDirectory:&isDir] && isDir) return YES;
if ([self fileExistsAtPath:directory isDirectory:&isDir] && !isDir) return NO;
return [self createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL];
}