Govind
Govind

Reputation: 2348

Same bundle identifier for OS X application and Preferences

I am developing an OS X application. For my app, there is a preference extension. I am trying to save all the preferences settings values of the application by using [NSUserDefaults standardUserDefaults]. In order to read the settings values from my application, can I use same bundle identifier for the preferences application and Cocoa application and Preference pane application?

Upvotes: 0

Views: 64

Answers (1)

andyvn22
andyvn22

Reputation: 14824

That's not recommended--the bundle identifier is not just for preferences. Each bundle should have a unique identifier. However, it's easy to use a custom NSUserDefaults to share some preferences (or all) between two bundles:

NSUserDefaults* defaults = [NSUserDefaults new];
[defaults addSuiteNamed:@"com.yourCompany.someSharedIdentifier"];

Simply use this object instead of standardUserDefaults for any preferences you wish for your two bundles to share.

Upvotes: 2

Related Questions