I am working on a C project that needs to save data to a persistent storage on the operating system.
For MacOS, I want to save the data to UserDefaults - is there a C library to manipulate them? Similar to NSUserDefaults in Objective-C.
CodePudding user response:
There are plain C functions in CoreFoundation which you can use directly, the CFPreference* family, but they might be rather awkward to use. See for example CFPreferencesSetAppValue and the CFPreferenceCopy* and CFPreferenceGet* functions. You're going to have to convert C from/to CoreFoundation data types.
You probably want to write some convenience wrappers. In that case, writing an Objective-C file and accessing NSUserDefaults instead might be an option.
