Created
March 27, 2024 06:29
-
-
Save hishd/e37ccf2f090d7aa10359ae1f95ac76b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Foundation | |
@dynamicMemberLookup | |
struct AppConfig { | |
let weatherApiKey: String = "" | |
private init() {} | |
static subscript<T>(dynamicMember keyPath:KeyPath<AppConfig, T>) -> T { | |
AppConfig()[keyPath: keyPath] | |
} | |
} | |
//MARK: Accessing the data (Autocomplete does not work due to dynamicMemberLookup) | |
let key = AppConfig.weatherApiKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment