Last active
May 27, 2017 20:18
-
-
Save allanalves/1a310899f9862a8eef46c82423bcd221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Environment: String { | |
case production | |
case homologation | |
case development | |
case custom | |
} | |
static func preferredEnvironment() -> Environment { | |
if let env = UserDefaults.standard.string(forKey: "environment") { | |
return Environment(rawValue: env)! | |
} | |
return Environment.production | |
} | |
static func enviromentUrl(_ environment: Environment) -> URL? { | |
if let path = Bundle.main.url(forResource: "Service", withExtension: "plist"), | |
let data = try? Data(contentsOf: path) { | |
if let result = try! PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String:String] { | |
return URL(string: result[environment.rawValue]!) | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment