• 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: How to tell if iTunes is running.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to tell if iTunes is running.


  • Subject: Re: How to tell if iTunes is running.
  • From: Steve Christensen <email@hidden>
  • Date: Sat, 24 May 2008 14:13:23 -0700

My version wasn't about using the path for something else; it was only about providing a method that doesn't care what the iTunes application is called. For example, if someone were to rename it "iTunes 7.6.2", then your version would stop working.

However, as Thomas Engelmeier pointed out in a separate message, Apple doesn't currently localize the names of its iApps so you're probably safe.


On May 24, 2008, at 12:17 PM, Mr. Gecko wrote:

because I do not need the path for what I am doing.



On May 24, 2008, at 2:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with localization or if the user renames iTunes for some reason.

iTunesIsOpen = NO;
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* iTunesPath = [workspace absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"];
NSArray* lApplications = [workspace launchedApplications];
int lAppsCount = [lApplications count];
int a;
for (a = 0; a < lAppsCount; a++)
{
NSDictionary* applicationD = [lApplications objectAtIndex:a];
if ([[applicationD objectForKey:@"NSApplicationPath"] isEqualToString:iTunesPath])
{
iTunesIsOpen = YES;
break;
}
}


[iTunesLMenu setTitle: NSLocalizedString(iTunesIsOpen ? @"Quit iTunes" : @"Launch iTunes",@"")];


On May 24, 2008, at 8:29 AM, Mr. Gecko wrote:

Thanks I am using this
iTunesIsOpen = NO;
[iTunesLMenu setTitle: NSLocalizedString(@"Launch iTunes",@"")];
NSArray *lApplications = [[NSWorkspace sharedWorkspace] launchedApplications];
int a;
for (a=0; a<[lApplications count]; a++) {
NSDictionary *applicationD = [lApplications objectAtIndex:a];
if ([[applicationD objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
iTunesIsOpen = YES;
[iTunesLMenu setTitle: NSLocalizedString(@"Quit iTunes",@"")];
}
}
On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote:


On May 23, 2008, at 4:01 PM, Mr. Gecko wrote:

How can I tell if iTunes is running with cocoa.

In this particular case, you should be able to get that information using -[NSWorkspace launchedApplications]...

_______________________________________________

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


References: 
 >How to tell if iTunes is running. (From: "Mr. Gecko" <email@hidden>)
 >Re: How to tell if iTunes is running. (From: Nick Zitzmann <email@hidden>)
 >Re: How to tell if iTunes is running. (From: "Mr. Gecko" <email@hidden>)
 >Re: How to tell if iTunes is running. (From: Steve Christensen <email@hidden>)

  • Prev by Date: Re: How to tell if iTunes is running.
  • Next by Date: Re: How to tell if iTunes is running.
  • Previous by thread: Re: How to tell if iTunes is running.
  • Next by thread: Re: How to tell if iTunes is running.
  • Index(es):
    • Date
    • Thread