Re: Using NSWorkspace's launchedApplication to detect running App
Re: Using NSWorkspace's launchedApplication to detect running App
- Subject: Re: Using NSWorkspace's launchedApplication to detect running App
- From: Andy Lee <email@hidden>
- Date: Sun, 14 Dec 2008 07:21:45 -0500
On Dec 14, 2008, at 6:35 AM, John Love wrote:
BOOL ExcelActive = NO;
NSWorkspace *workSpace;
NSArray *runningAppDictionaries;
NSDictionary *aDictionary;
workSpace = [NSWorkspace sharedWorkspace];
runningAppDictionaries = [workSpace launchedApplications];
for (aDictionary in runningAppDictionaries) {
if ([[aDictionary valueForKey:@"NSApplicationName"]
isEqualToString:@"Microsoft Excel"]) {
ExcelActive = YES;
break;
}
}
return ExcelActive;
Same NO return value.
Works for me. What do you see if you NSLog the application name in
each iteration of the loop?
for (aDictionary in runningAppDictionaries) {
NSLog(@"app name: [%@]", [aDictionary
valueForKey:@"NSApplicationName"]);
if ([[aDictionary valueForKey:@"NSApplicationName"]
isEqualToString:@"Microsoft Excel"]) {
And is there some reason you break with Cocoa coding convention by
naming a local variable ExcelActive instead of excelActive?
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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