How to remove tmp directory files of an ios app?

前端 未结 6 1007
囚心锁ツ
囚心锁ツ 2020-12-05 02:18

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.

6条回答
  •  孤街浪徒
    2020-12-05 02:44

    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];
        }
    }
    

提交回复
热议问题