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: John Love <email@hidden>
- Date: Sun, 14 Dec 2008 06:35:15 -0500
On Dec 13, 08, at 12:21 PM, Jean-Daniel Dupas wrote:
Because operator overriding does not exists in Obj-C and so, == is a
pointer comparaison and not a string comparaison.
use the isEqual: method to compare two object.
Thanks to everyone who chimed in .. and here are my changes:
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.
I then tried this variation, with the same NO return value:
NSArray *applArray;
applArray = [[[[NSWorkspace sharedWorkspace] launchedApplications]
filteredArrayUsingPredicate:[NSPredicate
predicateWithFormat:
@"%K contains %@", @"NSApplicationName",
@"Microsoft Excel"]]
valueForKey:@"NSApplicationName"];
if ([applArray count] > 0) return YES;
else return NO;
One footnote .. there are problems with Microsoft Excel as reported by
HAS of appscript. He points out difficulties with Excel, in
particular, with respect to Excel documents. Don't know about the app-
level.
_______________________________________________
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