Why does my string constant kAppCacheKey evaluate to an empty string the first time I access it? It shows up as the string "myAccount" on subsequent calls to it.
Am I declaring static constants in the right way?
let kAppCacheKey = "myAccount"
class LoggedUser {
class var sharedInstance: LoggedUser {
struct Static {
static let instance = LoggedUser.loadFromCache()
}
return Static.instance
}
override private init() {
super.init()
}
private class func loadFromCache() -> LoggedUser {
//kAppCacheKey is evaluated as an empty string here for some reason
if let data = Locksmith.loadDataForUserAccount(kAppCacheKey) as? [String:String]
{
}
}