Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read another app's preferences plist, or share some prefs?

I'd like to share a preference between two apps (a game and its editor). How can I best accomplish this? I thought the game could explicitly read from the editor's preferences plist, but I'm not sure what the cleanest way to achieve this is.

like image 861
andyvn22 Avatar asked Feb 03 '12 02:02

andyvn22


2 Answers

NSUserDefaults maintains a list of domains to search. By default it just looks at your application's preferences file, but you can have it search other places.

You can do something like this:

NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
[defaults addSuiteNamed:@"com.example.game.shared-prefs"];

To share preferences between apps.

like image 74
benzado Avatar answered Nov 17 '22 23:11

benzado


Just drop down to CFPreferences APIs for the expert parameters. NSUserDefaults' idea of preferences is for an app, but CFPreferences allow you to defines hosts, suites, and so on for the type of multi-app preferences you want.

like image 41
justin Avatar answered Nov 17 '22 23:11

justin