Reputation: 279
I'm developing a PreferencePane in Xcode 4.1, and I can't seem to get it to store the preference values in anything other than com.apple.systempreferences.plist.
I have set the Bundle Identifier for my app in the MyApp-Info.plist file, but this does not seem to be getting picked up.
I have searched extensively for an answer, but cannot find any. You can easily replicate the problem as follows:
In XCode:
In System Preferences:
But why doesn't it create a new plist file with your specified bundle identifier, and store the preference value in there?
Is this a bug in Xcode 4.1 / Mac OS 10.7 ? Any help much appreciated!
Upvotes: 0
Views: 1684
Reputation: 46020
You can use NSUserDefaults
to access the defaults for your bundle ID:
[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"yourBundleID"];
This will return a dictionary with the preferences for your bundle. You can then use the setPersistentDomain:forName:
method of NSUserDefaults
to store an updated preferences dictionary.
Upvotes: 3
Reputation: 410602
Not a bug -- preferences are stored into the plist corresponding to the application, not the bundle. You'll have to use the Core Foundation prefs system to read and write preferences specific to your bundle.
Upvotes: 0