以编程方式清除iPhone上的辅助缓存

编程入门 行业动态 更新时间:2024-10-24 00:28:00
本文介绍了以编程方式清除iPhone上的辅助缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个应用程序,我将在其中从服务器下载图像并将其本地存储在iPhone的文件系统中.它发生的很好.现在的问题是,当我退出应用程序时,我想清除iPhone上的本地缓存图像.

I have created an application , where i ll be downloading the images from server and storing it locally on the iPhone's file system. Its happening fine. Now the problem is , i want to clear the locally cached images on iPhone when ever i quit my application.

如何在iPhone上删除那些缓存的图像.它在iPhone上使用辅助存储器,我如何以编程方式访问它?

How do i delete those cached images on iPhone. it's using Secondary memory on iPhone, how do i access it programmatically ?

先谢谢您. 苏斯.

推荐答案

在applicationWillTerminate方法中清理它们.

Clean them up in your applicationWillTerminate method.

- (void)applicationWillTerminate:(UIApplication *)application { NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *imagesFiles = [fileManager contentsOfDirectoryAtPath:saveDirectory error:error]; for (NSString *file in imagesFiles) { error = nil; [fileManager removeItemAtPath:[saveDirectory stringByAppendingPathComponent:file] error:error]; /* do error handling here */ } }

更多推荐

以编程方式清除iPhone上的辅助缓存

本文发布于:2023-11-24 08:56:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624554.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   方式   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!