• 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: Using NSWorkspace's launchedApplication to detect running App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Using NSWorkspace's launchedApplication to detect running App
      • From: Andy Lee <email@hidden>
References: 
 >Using NSWorkspace's launchedApplication to detect running App (From: John Love <email@hidden>)
 >Re: Using NSWorkspace's launchedApplication to detect running App (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]
  • Next by Date: Re: Using NSWorkspace's launchedApplication to detect running App
  • Previous by thread: Re: Using NSWorkspace's launchedApplication to detect running App
  • Next by thread: Re: Using NSWorkspace's launchedApplication to detect running App
  • Index(es):
    • Date
    • Thread