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
I found this feature here in another tool which is putting the parsing keys in a struct for reuse preventing duplication in the keys.
EX.
`private struct SerializationKeys {
static let Id = "Id"
static let timeRange = "timeRange"
}`
This is to be used like this:
`init(fromDictionary dictionary: [String:Any]){
Id = dictionary[SerializationKeys.Id] as? Int
if let timeRangeData = dictionary[SerializationKeys.timeRange] as? [String:Any]{
timeRange = TimeRange(fromDictionary: timeRangeData)
}
}`
and like this:
`func toDictionary() -> [String:Any]
{
var dictionary = String:Any
if Id != nil{
dictionary[SerializationKeys.Id] = Id
}
if timeRange != nil{
dictionary[SerializationKeys.timeRange] = timeRange.toDictionary()
}
return dictionary
}`
The text was updated successfully, but these errors were encountered:
I found this feature here in another tool which is putting the parsing keys in a struct for reuse preventing duplication in the keys.
EX.
`private struct SerializationKeys {
}`
This is to be used like this:
`init(fromDictionary dictionary: [String:Any]){
and like this:
`func toDictionary() -> [String:Any]
{
var dictionary = String:Any
The text was updated successfully, but these errors were encountered: