I am facing issues while using init(from decoder: Decoder)
in Model extension in different module.
I have model in Module 1 as below
public struct LabelModel {
public var value: String?
}
And I have decodable extension in module 2
extension LabelModel: Decodable {
enum CodingKeys: String, CodingKey {
case value
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
value = try container.decodeIfPresent(String.self, forKey: .value) // error - 'self' used before 'self.init' call or assignment to 'self'
} // error - 'self.init' isn't called on all paths before returning from initializer
}
I am facing 2 errors while adding model extension with decodable in different module.
Any suggestion will be helpful for me.
Thanks in advance.