tags:

views:

157

answers:

1

Given, a file of path [[self documentsDirectory] stringByAppendingPathComponent:@"myFiles/aFile.txt"], How do I delete a file in my apps documents directory?

+7  A: 

NSFileManager is a very handy tool:

[[NSFileManager defaultManager] removeItemAtPath: pathToFile error: &error];
Ben Gottlieb
removeItemAtURL:error: is another useful NSFileManager method. I find that URLs are often easier to work with than paths.
John M. P. Knox