• 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: NSWorkspace openFile: bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWorkspace openFile: bug?


  • Subject: Re: NSWorkspace openFile: bug?
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 5 Jan 2007 14:20:44 -0500
  • Organization: Rogue Research

On 2007-01-05 10:51, Paul Borokhov said:

>Hello,
>It seems that I've run into a bit of an openFile: bug. Using this code:
>
> NSArray *paths = NSSearchPathForDirectoriesInDomains
>(NSLibraryDirectory, NSAllDomainsMask, YES);
> int i = 0;
> for (i; i<[paths count]; i++) { // 4 domains possible...there needs to
>be a better way of doing this
> 	if ([[NSWorkspace sharedWorkspace] openFile:[[paths objectAtIndex:i]
>stringByAppendingPathComponent:@"PreferencePanes/Growl.prefPane"]]) {
> 		NSLog(@"Found Growl");
>		i++;
>		break;
>	}
> }

Not sure about your exact question, but are you trying to display the
Growl pref pane to the user?

If so, I suggest this instead, it works well in my app:

- (IBAction)handleOpenGrowlPrefs:(id)sender
{
	BOOL	success = NO;
	if ([GrowlApplicationBridge isGrowlInstalled]) {
		NSString*					scriptStr = @"tell application \"System Preferences\"\n
activate\n set current pane to pane \"com.growl.prefpanel\"\n end tell";
		NSAppleScript*				script = [[[NSAppleScript alloc]
initWithSource:scriptStr] autorelease];
		NSDictionary*				errInfo;
		NSAppleEventDescriptor*		res = [script executeAndReturnError:&errInfo];
		success = (res != nil);
	}

	if (success == NO) {
		NSBeep ();
	}
}

It makes many less assumptions than your code, so should be safer.  It's
bad to assume 'PreferencePanes' and 'Growl.prefPane' will never change
name.  Bundle identifiers are forever(TM). :)  (Of course, Cocoa provides
no constant for getting at the PreferencePanes folder, but the Folder
Manager does, kPreferencePanesFolderType.)

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSWorkspace openFile: bug? (From: Paul Borokhov <email@hidden>)

  • Prev by Date: Re: NSWorkspace openFile: bug?
  • Next by Date: previousResponder?
  • Previous by thread: Re: NSWorkspace openFile: bug?
  • Next by thread: previousResponder?
  • Index(es):
    • Date
    • Thread