You force to deploy a possible (and actual) nil object.
return _bundle.objectForInfoDictionaryKey(key) as! String
NSBundle objectForInfoDictionaryKey can return nil - its expression:
func objectForInfoDictionaryKey(key: String) -> AnyObject?
my editing as a playground:
import Foundation class Settings { private static var _bundle = NSBundle.mainBundle() static func getDefaultString(key: String) -> String? { return _bundle.objectForInfoDictionaryKey(key) as? String } private static var _server = Settings.getDefaultString("DefaultServer") class var server: String? { get { return _server } set { _server = newValue } } } Settings.server
You can, of course, back out from nil some other way if you want.
source share