Search code examples
objective-ccocoaplistnsuserdefaults

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.


Solution

  • 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.