Re: Accessing System Preferences?
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.