You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keyNotFound No value associated with key CodingKeys
This throws on the accessCodes variable.
I have a custom Codable object that encodes just fine, but I believe that Codable does not encode empty arrays, so when I try to decode, your firebaseDecoder throws an error.
I have to provide a custom decoder init when I have any arrays that can be empty, and I don't append to initially.
This the husk of my class:
class UserSettings {
required init(from decoder: Decoder) throws {
let map = try decoder.container(keyedBy: CodingKeys.self)
userInfo = try map.decodeIfPresent(.userInfo)
activeAccessCode = try map.decodeIfPresent(.activeAccessCode)
accessCodes = try map.decodeIfPresent([UserAccessCode].self, forKey: .accessCodes) ?? []
activeTeam = try map.decodeIfPresent(.activeTeam)
teams = try map.decodeIfPresent([String].self, forKey: .teams) ?? []
activeEventID = try map.decodeIfPresent(.activeEventID)
isManager = try map.decodeIfPresent(.isManager) ?? false
}
var userInfo: UserInfo?
var activeAccessCode: UserAccessCode?
var accessCodes = [UserAccessCode]()
var activeTeam: String?
var teams = [String]()
var activeEventID: String?
var isManager: Bool = false
}
The text was updated successfully, but these errors were encountered:
keyNotFound No value associated with key CodingKeys
This throws on the accessCodes variable.
I have a custom Codable object that encodes just fine, but I believe that Codable does not encode empty arrays, so when I try to decode, your firebaseDecoder throws an error.
I have to provide a custom decoder init when I have any arrays that can be empty, and I don't append to initially.
This the husk of my class:
class UserSettings {
}
The text was updated successfully, but these errors were encountered: