Clear your application cache
This is my first share, and I'm sharing it because it took me a while to find it. If you ever need to clear you application cache, which is quite common for us here since we cache a lot of images in the QThru app, simply put this single line in your app delegate:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
I recommend you call this in any cleanup steps you have that prepare the app for a fresh installation, whether on app deletion or first time app use.
For example:
// This flag checks for a fresh installation of the app. If it is a fresh installation, do important stuff like clearing the previous PIN
BOOL isNotFirstTimeRun = [[NSUserDefaults standardUserDefaults] boolForKey:IS_NOT_FIRST_TIME_RUN];
if (!isNotFirstTimeRun) {
// Delete Keychain items
// Clear the cache if this is a first time run
[[NSURLCache sharedURLCache] removeAllCachedResponses];
// Set the flag to true and synchronize the user defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:IS_NOT_FIRST_TIME_RUN];
[defaults synchronize];
}
Written by Matt Gamboa
Related protips
1 Response
For iPhone users, you can try this way.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Caching
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#