• 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: Reading System Preferences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading System Preferences


  • Subject: Re: Reading System Preferences
  • From: David Thorup <email@hidden>
  • Date: Fri, 1 Aug 2003 18:43:10 -0600

On Friday, August 1, 2003, at 4:06 PM, Seth Willits wrote:

I'm trying to read the homepage preference set in the System Preferences. I looked in the plist files to find what the key was, changed it in System Prefs to make sure I was looking the right one and then tried to read it in Cocoa like in the code below but there's no string found for the key.

I must be missing something, but I've read the NSUserDefaults section in Cocoa Programming and looked in the Apple documentation but I can't find anything.


[[NSUserDefaults standardUserDefaults] stringForKey:@"WWWHomePage"]

The WWWHomePage key is not in a place that will be read using the command you provided. The WWWHomePage is located in:

com.apple.interenetconfig->Version 2.5.4->ic-added->WWWHomePage

Each key in the path above returns a dictionary. So in order to get the WWWHomePage key you'd need to do something like this (Note: typed in Mail, not tested, use at your own risk):

--------------------------
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSDictionary* dict; // the WWWHomePage key returns a dictionary
NSString* homePage;

dict = [[[[defaults persistentDomainForName:@"com.apple.interenetconfig"]
objectForKey:@"Version 2.5.4"]
objectForKey:@"ic-added"]
objectForKey:@"WWWHomePage"];

homePage = [dict objectForKey:@"ic-data"];
--------------------------

By the way, I found all this information in about a second with Defaults Manager (http://www.kuwan.net/defaultsmanager). All I did was search for the string "WWWHomePage" and Defaults Manager showed me right where it was.
_____________________________

Dave Thorup
Software Engineer
email@hidden

http://www.kuwan.net
Defaults Manager - The premier editor for Mac OS X's User Defaults / Preferences database.
_______________________________________________
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.
  • Follow-Ups:
    • Re: Reading System Preferences
      • From: Seth Willits <email@hidden>
References: 
 >Reading System Preferences (From: Seth Willits <email@hidden>)

  • Prev by Date: Using C++ and ObjC FAC
  • Next by Date: Re: Seeking contacts and advice on finding work in programming for the Mac
  • Previous by thread: Reading System Preferences
  • Next by thread: Re: Reading System Preferences
  • Index(es):
    • Date
    • Thread