Skip to content

Instantly share code, notes, and snippets.

@viccc
Created March 10, 2017 08:15
Show Gist options
  • Save viccc/36813311560d3ec92c7455584a6d9c5f to your computer and use it in GitHub Desktop.
Save viccc/36813311560d3ec92c7455584a6d9c5f to your computer and use it in GitHub Desktop.
extension NSBundle {
static func appDisplayName(context: NSFormattingContext) -> String {
if let str = NSBundle.mainBundle().localizedInfoDictionary?["CFBundleDisplayName"] as? String {
return str
}
if let str = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleDisplayName") as? String {
return str
}
if let str = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? String {
return str
}
switch context {
case .BeginningOfSentence:
return "The app"
case .MiddleOfSentence, .Unknown:
return "the app"
case .Standalone, .ListItem:
return "The App"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment