Wednesday, October 19, 2011

iOS5 NSURLCache Problem

I recently ran into some code where the programmer was trying to clear the web cache using:


    NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
    [NSURLCache setSharedURLCache:sharedCache];
    [sharedCache release];  

I found that out by going to this url:

http://stackoverflow.com/questions/2523435/how-to-clear-uiwebview-cache

This worked fine in iOS 4, but once the official iOS 5 was released this crashed the app.

From Stack Overflow the 2nd comment worked:

// Flush all cached data
[[NSURLCache sharedURLCache] removeAllCachedResponses];

No comments:

Post a Comment