Skip to content

Instantly share code, notes, and snippets.

@scottjacksonx
Created July 10, 2012 06:00
Show Gist options
  • Save scottjacksonx/3081450 to your computer and use it in GitHub Desktop.
Save scottjacksonx/3081450 to your computer and use it in GitHub Desktop.
From an app bundle identifier, return the name of that app
//
// NSString+AppName.h
//
// Created by Scott Jackson on 4/07/12.
// Copyright (c) 2012 SJSoftware. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (AppName)
+ (NSString *)nameOfApplicationWithBundleIdentifier:(NSString *)bundleIdentifier;
@end
//
// NSString+AppName.m
//
// Created by Scott Jackson on 4/07/12.
// Copyright (c) 2012 SJSoftware. All rights reserved.
//
#import "NSString+AppName.h"
@implementation NSString (AppName)
+ (NSString *)nameOfApplicationWithBundleIdentifier:(NSString *)bundleIdentifier {
NSString *bundlePath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:bundleIdentifier];
NSBundle *appBundle = [NSBundle bundleWithPath:bundlePath];
return [appBundle objectForInfoDictionaryKey:(id)kCFBundleNameKey];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment