如何删除应用程序文档目录中的文件?
问题描述:
给定,文件路径 [[self documentsDirectory] stringByAppendingPathComponent:@myFiles / aFile.txt]
,如何删除应用文档目录中的文件?
Given, a file of path [[self documentsDirectory] stringByAppendingPathComponent:@"myFiles/aFile.txt"]
, How do I delete a file in my apps documents directory?
答
NSFileManager是一个非常方便的工具:
NSFileManager is a very handy tool:
[[NSFileManager defaultManager] removeItemAtPath: pathToFile error: &error];