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

Re: Accessing System Preferences?


  • Subject: Re: Accessing System Preferences?
  • From: Nick Morris <email@hidden>
  • Date: Tue, 19 Aug 2003 18:46:58 +0100

Hi,

Thanks for all the replies and suggestions (sorry for the delay in a follow-up).

Summary of problem:

How do I retrieve the System Preference setting for Mail and Web for a user?

Basically, it is just so the right Applescript fires in my application for the right mail program or web-broswer.

Solution:

Two solutions were suggested (thanks to Seth, Scott, Matt, and Creed) and I have tried both.

Solution 1

NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSDictionary* dict;
NSString* homePage;

dict = [defaults persistentDomainForName:@"com.apple.internetconfig"];
NSString * versionKey = [[dict keyEnumerator] nextObject];

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

Tried this and it worked. However, I was a bit concerned about some of the comments made by the other members of the list.

I finally went with:

NSURL *appURL = nil;
OSStatus err;

err = LSGetApplicationForURL((CFURLRef)[NSURL URLWithString: @"mailto:"],kLSRolesAll, NULL, (CFURLRef*)&appURL);

if (err != noErr)
{
return @"error";
} else {
return ([[[appURL path] lastPathComponent] stringByDeletingPathExtension]);
}

(I still find it surprising that there is not an easier solution to this based on on NSUserDefaults.)

Thanks again for all your help.

Nick
_______________________________________________
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: NSOutlineView in a Drawer reloaded from Sheet NSButton
  • Next by Date: Re: Cocoa Speech Wrapper?
  • Previous by thread: Re: Accessing System Preferences?
  • Next by thread: #Import problems
  • Index(es):
    • Date
    • Thread