2 // NSRunningApplication+NJPossibleNames.m
5 // Created by Joe Wreschnig on 3/8/13.
9 #import "NSRunningApplication+NJPossibleNames.h"
11 @implementation NSRunningApplication (NJPossibleNames)
13 - (NSArray *)possibleMappingNames {
14 NSMutableArray *names = [[NSMutableArray alloc] initWithCapacity:4];
15 if (self.bundleIdentifier)
16 [names addObject:self.bundleIdentifier];
17 if (self.localizedName)
18 [names addObject:self.localizedName];
20 [names addObject:[self.bundleURL.lastPathComponent stringByDeletingPathExtension]];
21 if (self.executableURL)
22 [names addObject:self.executableURL.lastPathComponent];
26 - (NSString *)bestMappingName {
27 // A number of Flash applications all use the generic Flash bundle
28 // ID and localized name, but they name their bundle file and
29 // executable correctly. Don't want to fall back to those IDs
30 // unless we absolutely have to.
31 NSArray *genericBundles = @[
32 @"com.macromedia.Flash Player Debugger.app",
33 @"com.macromedia.Flash Player.app",
35 BOOL probablyWrong = [genericBundles containsObject:self.bundleIdentifier];
36 if (!probablyWrong && self.localizedName)
37 return self.localizedName;
38 else if (!probablyWrong && self.bundleIdentifier)
39 return self.bundleIdentifier;
40 else if (self.bundleURL)
41 return [self.bundleURL.lastPathComponent stringByDeletingPathExtension];
42 else if (self.executableURL)
43 return self.executableURL.lastPathComponent;
44 else if (self.localizedName)
45 return self.localizedName;
46 else if (self.bundleIdentifier)
47 return self.bundleIdentifier;
49 return NSLocalizedString(@"@Application",
50 @"Magic string to trigger automatic "
51 @"mapping renames. It should look like "
52 @"an identifier rather than normal "
53 @"word, with the @ on the front.");