Clearing NSUserDefaults
- 10月
- 06
- Posted by Lin
- Posted in iOS & Object-c
There are many ways to store data in an iOS app.
Core Data, SQLite and UIDocuments are all available but often the quick and easy way to store some data is to use NSUserDefaults.
Sometimes we need to clear all of NSUserDefaults data in your app. And there are two ways to clear it.
1.Delete all keys from NSUserDefaults dictionary.
[css] – (void)resetDefaults { NSUserDefaults * defs = [NSUserDefaults standardUserDefaults]; NSDictionary * dict = [defs dictionaryRepresentation]; for (id key in dict) { [defs removeObjectForKey:key]; } [defs synchronize]; } [/css]2.Use NSUserDefaults removePersistentDomainForName method.
[css] NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; [/css] You can try both of them.Comment
[do_widget “Facebook Comments Master”]近期文章
- Salesforce DevTools的开发者用户突破10,000名!THANK YOU!
- Lightning Component中使用Promise处理Apex服务端请求
- Pipeline for Salesforce – Be less busy, less mistake in Salesforce metadata deploy
- Salesforce Smart Importer – 1-Drag to import Excel / CSV in Salesforce, supports both Classic and Lightning!
- 用Visual Studio Code架设Salesforce DX的快速开发IDE环境
Top Posts
- 用Sublime Text 3架设Salesforce的快速开发环境 - 102.9K views
- Salesforce DevTools – Saleforce.com开发者必备Chrome扩展 - 102.2K views
- Salesforce批量编辑 (Chrome扩展) – 在任何标准视图上进行批量插入, 拷贝, 更新, 删除, 支持Classic与Lightning! - 65.5K views
- Date format 与 DateTime format - 58.7K views
- 编写一个可被计划执行的Batch Apex - 51.6K views
分类目录
- APEX
- 应用
- Custom Label
- Custom Metadata
- Custom Setting
- Design & UI
- 交流会
- Heroku
- iOS & Object-c
- Lightnint Component
- Linux & Mac OS
- Metadata API
- Node.js
- Open Source
- Other
- PHP Framework
- Release Notes
- REST API
- Salesforce
- Salesforce DX
- SOQL
- Tesforce
- Tooling API
- Unit Tests
- Validation Rule
- Visualforce
- WordPress