这是本人开发ios用来清除语音缓存的方法,主要是删除document等文件夹目录下面的所有文件,方法很简单,如下。//清除语音缓存
- (void)clearVoiceCache{
//找到所要删除文件的目录
NSString *voiceRootPath = [NSString stringWithFormat:@"%@/Library/appdata/chatbuffer", NSHomeDirectory()];
//遍历获取文件名
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:voiceRootPath];
for (NSString *fileName in enumerator) {
//拼接文件所在地址
NSString *voicePath = [voiceRootPath stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] removeItemAtPath:voicePath error:nil];
}
}
来源网站:太平洋学习网,转载请注明出处:http://www.tpyyes.com/a/object-c_ios/139.html