开发者

Clear Absolute Cache on Application close Ipad app

I am saving Images in NS开发者_开发技巧CachesDirectory in a App. At the end of app execution i would like to clear all temporary cache. Is there a way to force clear all cache on application exit. I do realise the local folder keeps cache for 3 days..but my requirement is to force clear the Cache. Thx


This code should do the trick, just substitute the name of your cache directory...

    NSString *cacheDirectoryName = [self getCacheDirectoryName];
    NSArray *items = [fileManager directoryContentsAtPath:cacheDirectoryName];
    for (NSString *item in items)
    {
      NSString *path = [cacheDirectoryName stringByAppendingPathComponent:item];
      NSError *error = nil;
      [fileManager removeItemAtPath:path error:&error];
      [error release];
    }

Then call the code in your AppDelegate applicationWillTerminate method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜