Return to Snippet

Revision: 28820
at July 14, 2010 23:44 by rabc


Initial Code
- (void)deleteFilesFromDocuments {
	NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
	NSFileManager* fm = [[[NSFileManager alloc] init] autorelease];
	NSDirectoryEnumerator* en = [fm enumeratorAtPath:path];    
	NSError* err = nil;
	BOOL res;
	NSString* file;
	while (file = [en nextObject]) {
		
		if ([file rangeOfString:@".sqlite"].location == NSNotFound) {
			res = [fm removeItemAtPath:[path stringByAppendingPathComponent:file] error:&err];
			if (!res && err) {
				NSLog(@"oops: %@", err);
			}
		}
	}
}

Initial URL

                                

Initial Description
Delete the files in Documents folder if it's not a sqlite file.

Initial Title
Delete files from Documents folder

Initial Tags
iphone

Initial Language
Objective C