Browse files

adding bundleIdentifierForApplication:

  • Loading branch information...
1 parent cf9e1a6 commit d39a595f9653745ad346f2a9ee4976779780fdde @Machx committed May 18, 2011
Showing with 16 additions and 0 deletions.
  1. +1 −0 Source/CWApplicationRegistry.h
  2. +15 −0 Source/CWApplicationRegistry.m
View
1 Source/CWApplicationRegistry.h
@@ -14,5 +14,6 @@ static const NSInteger kPidNotFound = -1;
+(BOOL)applicationIsRunning:(NSString *)appName;
+(NSInteger)pidForApplication:(NSString *)appName;
++(NSString *)bundleIdentifierForApplication:(NSString *)appName;
@end
View
15 Source/CWApplicationRegistry.m
@@ -53,4 +53,19 @@ +(NSInteger)pidForApplication:(NSString *)appName {
return pid;
}
++(NSString *)bundleIdentifierForApplication:(NSString *)appName {
+ __block NSString *bundleIdentifier = nil;
+
+ NSArray *applications = [[NSWorkspace sharedWorkspace] runningApplications];
+ [applications cw_each:^(id obj){
+ NSRunningApplication *app = (NSRunningApplication *)obj;
+
+ if ([[app localizedName] isEqualToString:appName]) {
+ bundleIdentifier = [app bundleIdentifier];
+ }
+ }];
+
+ return bundleIdentifier;
+}
+
@end

0 comments on commit d39a595

Please sign in to comment.