Is there any way to clear all data stored from the installation of app?

こ雲淡風輕ζ 提交于 2019-12-06 04:14:42

Try

 NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
 [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];

or

[[NSUserDefaults standardUserDefaults] setPersistentDomain:[NSDictionary dictionary] forName:[[NSBundle mainBundle] bundleIdentifier]];

You could try this

NSUserDefaults

  NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
  [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];

or

NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
NSDictionary * dict = [defs dictionaryRepresentation];
for (id key in dict) {
    [defs removeObjectForKey:key];
}
[defs synchronize];

UIWebview Cache

[NSURLCache sharedURLCache] removeAllCachedResponses];

//Delete cookies

 for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {

  if([[cookie domain] isEqualToString:someNSStringUrlDomain]) {

    [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
  }
 }

Try this,

 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"defunctPreference"];

Some of the caches are connected with other apps' information. You should be careful when you delete them. Just remind you to check before operating. I have made the similar stupid mistakes before. If you have found a great tool. Please share! Thanks.

You can try using [[NSURLCache sharedURLCache] removeAllCachedResponses];

For more details, refer to link http://iphonedevsdk.com/forum/iphone-sdk-development/104198-programmatically-clearing-app-cache.html

Henry H Miao

If you use NSUserDefaults, you may try this.

In terms of other cache files, I think you should keep all of them in a folder, so that they can be removed easily by removing the whole cache folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!