Reputation: 733
I have a small utility that I'm working on that duplicates a plist file to Dropbox so that I can sync that plist file across two computers. In 10.9, changes to preferences are cached and only written to disk when requested by an application or by cfprefsd.
Is it possible for me to use CFPreferencesAppSynchronize to tell the system to write the new presences of an arbitrary application to disk? For example, if I wanted to sync my finder preferences, could I have my little application call CFPreferencesAppSynchronize with respect to the finder (com.apple.finder)? The code below does not seem to work, but no error is thrown:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here..
NSString *stringApplicationID = @"com.apple.finder";
CFStringRef applicationIDfinder = (__bridge CFStringRef)stringApplicationID;
Boolean CFPreferencesSynchronize (
CFStringRef applicationIDfinder,
CFStringRef kCFPreferencesAnyUser,
CFStringRef kCFPreferencesAnyHost
);
return 0;
}
}
Upvotes: 0
Views: 765
Reputation: 41821
The change was in 10.8, actually, not 10.9 (though it changed further in 10.9). There is no reliable way to manipulate or interact with the on-disk plists, they are purely an implementation detail of the preferences system.
If you want to sync them, my suggestion would be to read the preferences and write them to the dropbox-synced location yourself with NSPropertyListSerialization. Then on the other side of the connection, read them yourself and set them in CFPreferences.
Upvotes: 1