This code works for one of our developers on 10.7 but not for me on 10.8
working = it deletes the preferences .plist file for the bundle. The dev on 10.7 also has a lockfile whereas I do not. It's not a problem of file access - I tried [resetStandardUserDefault] and that made a new file, but that's not exactly we want to do.
NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];
I am having trouble locating any info about changes in 10.8 - does this sound familiar to anyone?
I have the same issue and indeed there seems to be no info about any changes, also don't get any errors or warnings. [NSUserDefaults resetStandardUserDefault]
doesn't do anything for me. What I do currently is simply overwrite the default values to reset them (give [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:
[NSDictionary dictionaryWithObjectsAndKeys:...]]
the same input as originally given to [[NSUserDefaults standardUserDefaults] registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:...]]
.
Not really an answer, but I don't have enough rep to comment..
来源:https://stackoverflow.com/questions/13595415/osx-preferences-file-removepersistentdomainforname-has-different-functionality