Created
December 3, 2014 11:01
-
-
Save benbahrenburg/4f7794ece60831c14182 to your computer and use it in GitHub Desktop.
Creating ApplicationSupport Directory
This file contains 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
BOOL supportDirExists; // Add class level variable | |
//Update to FilesystemModule.m | |
//https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/FilesystemModule.m#L132 | |
-(NSString*)applicationSupportDirectory | |
{ | |
if(!supportDirExists){ | |
NSString *supportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject]; | |
if ([[NSFileManager defaultManager] fileExistsAtPath:supportDir isDirectory:NULL]) { | |
supportDirExists = YES; | |
}else{ | |
NSError *error = nil; | |
supportDirExists = [[NSFileManager defaultManager] createDirectoryAtPath:supportDir withIntermediateDirectories:YES attributes:nil error:&error]; | |
if(!supportDirExists){ | |
NSLog(@"[ERROR] %@", error.localizedDescription); | |
} | |
} | |
} | |
return [NSString stringWithFormat:@"%@/",fileURLify([NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0])]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment