NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenc
2013-05-17 11:26
507 查看
在iOS5.1以后的版本中,清除所有的NSUserDefaults Data的时候会报错,直接crash
在清除的时候用一下代码,问题解决。
在清除的时候用一下代码,问题解决。
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSDictionary *userDefaultsDictionary = [userDefaults dictionaryRepresentation]; NSString *strWebDatabaseDirectory = [userDefaultsDictionary objectForKey:@"WebDatabaseDirectory"]; NSString *strWebKitLocalStorageDatabasePathPreferenceKey = [userDefaultsDictionary objectForKey:@"WebKitLocalStorageDatabasePathPreferenceKey"]; [userDefaults removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]]; if (strWebDatabaseDirectory) { [userDefaults setObject:strWebDatabaseDirectory forKey:@"WebDatabaseDirectory"];} if (strWebKitLocalStorageDatabasePathPreferenceKey) { [userDefaults setObject:strWebKitLocalStorageDatabasePathPreferenceKey forKey:@"WebKitLocalStorageDatabasePathPreferenceKey"];} [userDefaults synchronize];
相关文章推荐
- ***-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from ob
- *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value ‘<Student: 0x8399f70>’
- 错误:*** -[NSUserDefaults setObject:forKey:]: attempt to insert non-property list object
- *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from o
- [__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from object
- 调用系统相机:[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from
- reason: '*** setObjectForKey: object cannot be nil (key: 1)'-crash!
- [__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from object
- *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x1701bcd20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the k
- How to add,edit and delete key-value in localStorage of Browse
- attempt to insert nil object from objects[1]' 错误
- iOS-报错[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
- 一个错误Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4b3c2a0> setValue:forUndefinedKey:]: this class i
- Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key
- 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to i
- xcode attempt to insert nil key
- reason: '[<__NSDictionary0 0x7fda88f00c90> setValue:forUndefinedKey:]: this class is not key value c
- KVO 接收变更通知 observeValueForKeyPath:ofObject:change:context:
- 我遇到的错误提示:reason: '*** setObjectForKey: object cannot be nil (key: id)' 的病因
- -observeValueForKeyPath:ofObject:change:context: message was received but not handled.