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

Re: Open System Preferences?


  • Subject: Re: Open System Preferences?
  • From: Ali Ozer <email@hidden>
  • Date: Sun, 16 Apr 2006 10:26:30 -0700

NSWorkspace is even a better form of this; a little more impedance match.
However in either the NSWorkspace or LaunchServices cases it would be best to get at the /System/Library folder dynamically, something like:


NSArray *paths = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, NSSystemDomainMask, NO);
return ([paths count] == 0) ? NO : [NSWorkspace openFile:[[paths objectAtIndex:0] stringByAppendingPathComponent:@"PreferencePanes/ Speech.prefPane"]];


Ali


On Apr 16, 2006, at 2:59 AM, Uli Kusterer wrote:

Am 16.04.2006 um 05:21 schrieb Andrei Tchijov:
[
[ NSTask
launchedTaskWithLaunchPath: @"/usr/bin/open"
arguments: [ NSArray arrayWithObject: [ @"<PATH TO THE PREFERENCE PANE YOU WANT TO OPEN>" stringByExpandingTildeInPath ]]
]
waitUntilExit
];

Is there anything wrong with using Launch Services directly? (untested code):


#import <LaunchServices/LaunchServices.h>

BOOL UKLaunchSpeechSettings( NSURL* *outLaunchedAppURL )
{
NSURL* myPrefPane = [NSURL fileURLWithPath: @"/System/Library/ PreferencePanes/Speech.prefPane"];
NSURL* launchedAppURL = nil;
OSStatus err = LSOpenCFURLRef( (CFURLRef) myPrefPane, (CFURLRef *) outLaunchedAppURL );
[(*outLaunchedAppURL) autorelease];


    if( err == noErr )
        return YES; // success.
    else
        return NO;
}

I don't see why everyone always keeps starting up command-line tools or even inserting placeholders in shell scripts when we have perfectly good APIs (and this time it's not even "evil Carbon").

Cheers,
-- M. Uli Kusterer
http://www.zathras.de

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Open System Preferences?
      • From: Uli Kusterer <email@hidden>
    • Re: Open System Preferences?
      • From: Rosyna <email@hidden>
References: 
 >Open System Preferences? (From: d2kagw <email@hidden>)
 >Re: Open System Preferences? (From: Andrei Tchijov <email@hidden>)
 >Re: Open System Preferences? (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Ideas to implement a view displaying a graph
  • Next by Date: Re: Empty NSStrings, nil NSStrings
  • Previous by thread: Re: Open System Preferences?
  • Next by thread: Re: Open System Preferences?
  • Index(es):
    • Date
    • Thread