Created
January 26, 2020 13:35
-
-
Save EnesKaraosman/31c5ad12922125ab5bca2930af66f5a1 to your computer and use it in GitHub Desktop.
Environment file for Settings.bundle demo
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 = "production" | |
case development = "development" | |
var url: String { | |
switch self { | |
case .development: | |
return "https://development.base.url/" | |
case .production: | |
return "https://production.base.url/" | |
} | |
} | |
static var selected: Environment { | |
// Settings.bundle dosyasından okuma yapalım | |
let defaultValue = Environment.production | |
if let environment = UserDefaults.standard.string(forKey: "environment") { | |
return Environment(rawValue: environment) ?? defaultValue | |
} | |
return defaultValue | |
// Settings.bundle' ı göz ardı etmek isteyeceğimiz bir durum olursa, | |
// burada istediğimiz case i dönebiliriz | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment