Skip to content

Instantly share code, notes, and snippets.

@yeahq
Created April 15, 2012 10:08
Show Gist options
  • Save yeahq/2391682 to your computer and use it in GitHub Desktop.
Save yeahq/2391682 to your computer and use it in GitHub Desktop.
Delete Directory
NSString *path;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SomeDirectoryName"];
NSError *error;
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) //Does directory exist?
{
if (![[NSFileManager defaultManager] removeItemAtPath:path error:&error]) //Delete it
{
NSLog(@"Delete directory error: %@", error);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment