0
点赞
收藏
分享

微信扫一扫

两种方法删除NSUserDefaults所有记录

​​//方法一​​

​​NSString​​​ ​​*appDomain = [[​​​​NSBundle​​​ ​​mainBundle​​​​]​​​ ​​bundleIdentifier​​​​];​​


​​[[​​​​NSUserDefaults​​​ ​​standardUserDefaults​​​​]​​​ ​​removePersistentDomainForName​​​​:appDomain];​​


​​//方法二​​

​​- (​​​​void​​​​)resetDefaults {​​


​​NSUserDefaults​​​ ​​* defs = [​​​​NSUserDefaults​​​ ​​standardUserDefaults​​​​];​​


​​NSDictionary​​​ ​​* dict = [defs​​​ ​​dictionaryRepresentation​​​​];​​


​​for​​​ ​​(​​​​id​​​ ​​key ​​​​in​​​ ​​dict) {​​


​​[defs​​​ ​​removeObjectForKey​​​​:key];​​


​​}​​


​​[defs​​​ ​​synchronize​​​​];​​

​​}​​

举报

相关推荐

0 条评论