本文介绍了以编程方式清除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上的辅助缓存
发布评论