Skip to content

Instantly share code, notes, and snippets.

@viccc
Created March 10, 2017 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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