如何删除ios应用程序的tmp目录文件? [英] How to remove tmp directory files of an ios app?

查看:83
本文介绍了如何删除ios应用程序的tmp目录文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 iPhone 相机的应用程序,经过多次测试后,我意识到它将所有捕获的视频存储在应用程序的 tmp 目录中.即使手机重新启动,捕获也不会消失.

I'm working on an app that uses the iPhone camera and after making several tests I've realised that it is storing all the captured videos on the tmp directory of the app. The captures don`t disappear even if the phone is restarted.

有什么方法可以删除所有这些捕获,或者有什么方法可以轻松清理所有缓存和临时文件?

Is there any way to remove all these captures or is there any way to easily clean all cache and temp files?

推荐答案

是的.这个方法效果很好:

Yes. This method works well:

+ (void)clearTmpDirectory
{
    NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
    for (NSString *file in tmpDirectory) {
        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
    }
}

这篇关于如何删除ios应用程序的tmp目录文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆