Skip to content

Instantly share code, notes, and snippets.

@matthewhudson
Created March 20, 2012 03:00
Show Gist options
  • Save matthewhudson/2130572 to your computer and use it in GitHub Desktop.
Save matthewhudson/2130572 to your computer and use it in GitHub Desktop.
Create folder if doesn't exist
// Documents directory
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask, YES)
objectAtIndex:0];
NSString *dataPath = [documentsPath stringByAppendingPathComponent:@"folderName"];
// Create folder if does not exist.
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath
withIntermediateDirectories:NO
attributes:nil
error:&error];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment