Where is the data for NSUserDefaults standardUserDefaults stored on MacOS? I would like to edit stored values as is possible in the Windows Registry. I am using XCode 12.3 on Catalina. Finder search does not show any non-source code file on the machine which contains the persisted values. No .plist files shown via Finder appear to store the persisted values.
Asked
Active
Viewed 216 times
0
-
Duplicate of [Where is a Mac Application's NSUserDefaults Data Stored?](https://stackoverflow.com/questions/7982740/where-is-a-mac-applications-nsuserdefaults-data-stored) – Willeke Mar 18 '21 at 10:45
-
None of the locations described in the duplicate question contain a .plist file containing the standardDefaults data. However, the data can be viewed by typing `po [[ NSUserDefaults standardUserDefaults ]persistentDomainForName:BundleIdentifier]`at the debug console. BundleIdentifier is shown in the General tab of the Project.xcodeproj file. – SimonKravis Mar 19 '21 at 11:40
-
How do you write to the user defaults? – Willeke Mar 19 '21 at 14:23
-
Writing to standardDefaults is done via the Bindings inspector for bound controls and via [[NSUserDefaults standardUserDefaults] setValue:
forKey: – SimonKravis Mar 20 '21 at 02:00for other values -
Does `~/Library/Containers/com.example.myapp/Data/Library/Preferences/com.example.myapp.plist` exist? When do you check? Can you read standardDefaults when you start the app? – Willeke Mar 20 '21 at 08:46
-
There is no directory MacHDD/Library/Containers – SimonKravis Mar 20 '21 at 08:58
-
See [what does “~/.” mean in terms of OS X folders/directories?](https://superuser.com/questions/158721/what-does-mean-in-terms-of-os-x-folders-directories) – Willeke Mar 20 '21 at 09:04
-
Have found the hidden folder /Users/apple/Library/containers (user name is Apple User) but there is no subfolder corresponding to the bundle identifier of the XCode project (ch.seriot.CocoaSlideShow) – SimonKravis Mar 20 '21 at 09:19
-
Found the file Users/apple/Library/Preferences/ch.seriot.CocoaSlideShow.plist which presumably contains the standardDefault preferences. Is there any way to show this file in Finder? – SimonKravis Mar 20 '21 at 09:28
-
Holding down cmd, shift and period shows hidden folders in Finder and inspection shows that the file above does contain the stadardDefaults preferences. Thanks! – SimonKravis Mar 20 '21 at 09:32
-
Deleting the file Users/apple/Library/Preferences/ch.seriot.CocoaSlideShow does not seem to affect the default values retrieved and neither does setting values from Xcode when the .plist file is opened in Xcode so perhaps this file does not contain the standardUserDefaults values. The values shown by `po [[ NSUserDefaults standardUserDefaults ]persistentDomainForName:BundleIdentifier]` are not identical to those shown in XCode. – SimonKravis Mar 29 '21 at 10:50