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: email@hidden
- Date: Sat, 13 Dec 2008 12:41:30 -0500
Specifically, in his case, wouldn't it be:
aDictionary valueForKey:@"NSApplicationName"] isEqualToString:
@"MyApplication"
?
Quoting Jean-Daniel Dupas <email@hidden>:
Le 13 déc. 08 à 18:14, John Love a écrit :
I do not understand why this code completes with the specified
application not being active .. when it really is? I really need
your help.
BOOL AppActive = NO;
NSWorkspace *workSpace;
NSArray *runningAppDictionaries;
NSDictionary *aDictionary;
workSpace = [NSWorkspace sharedWorkspace];
runningAppDictionaries = [workSpace launchedApplications];
for (aDictionary in runningAppDictionaries) {
if ([aDictionary valueForKey:@"NSApplicationName"] == @"My Application") {
AppActive = YES;
break;
}
}
return AppActive;
Thanks ...
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.
_______________________________________________
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
_______________________________________________
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