• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting bundle ID (was 'getting the bundle name')
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: ANNOUNCE: GNUMail.app 1.0.0
  • Next by Date: Drawing an arrowhead
  • Previous by thread: NSBundle classNamed: Problem
  • Next by thread: Drawing an arrowhead
  • Index(es):
    • Date
    • Thread