Re: getting bundle ID (was 'getting the bundle name')
Re: getting bundle ID (was 'getting the bundle name')
- Subject: Re: getting bundle ID (was 'getting the bundle name')
- From: Donald Hall <email@hidden>
- Date: Sun, 24 Mar 2002 23:49:37 -0700
Thanks to all who replied. Your help is greatly appreciated. I have it
working now. I did not realize that the bundle identifier was not the
same as the bundle name as it appears in the Finder, and that I would
have to set it.
I am trying the challenge at the end of Chapter 8 in Hillegass, which is
to provide a "Reset Preferences" button to restore preferences to
"factory" settings. I wanted to determine if the Application level of
defaults contained any keys for my application specific settings. (If
not, I disable the button.) According to the NSUserDefaults
documentation, to do this I need the bundle identifier to pass to the
persistentDomainForName method. The following revised code fragment
appears to work after I set the CFBundleIdentifier key in the Target
Application Settings:
NSUserDefaults *defaults;
NSString *bundleID;
NSBundle *myBundle;
NSDictionary *userDefaults;
defaults = [NSUserDefaults standardUserDefaults];
myBundle = [NSBundle mainBundle];
NSLog(@"main bundle is %@", myBundle);
bundleID= [myBundle bundleIdentifier];
NSLog(@"bundle identifier is %@", bundleID);
userDefaults = [defaults persistentDomainForName: bundleID];
NSLog(@"user defaults are: %@", userDefaults);
It also seems to work if I replace 'bundleID' with @"RaiseMan"
Thanks again John, Jonathan, and Ondra.
Don
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.