Error: method 'newInstance(_:context:)' in non-final class 'ChecklistItem' must return `Self` to conform to protocol 'JsonConvertibleType'
jefferythomas opened this issue · 1 comments
jefferythomas commented
I'm getting this error using Carthage install: github "LoganWright/Genome" "2.0.4"
Here is the source code
class ChecklistItem: MappableObject {
var title: String
var checked: Bool
init(title: String, checked: Bool) {
self.title = title
self.checked = checked
}
convenience init(title: String) {
self.init(title: title, checked: false)
}
required init(map: Map) throws {
self.title = try map.extract("title")
self.checked = try map.extract("checked")
}
func sequence(map: Map) throws {
try title ~> map["title"];
try checked ~> map["checked"];
}
}
extension ChecklistItem: Equatable { }
func == (lhs: ChecklistItem, rhs: ChecklistItem) -> Bool {
return lhs.checked == rhs.checked && lhs.title == rhs.title
}
loganwright commented
That issue arises from inheritance with classes and protocols getting crossed a bit due to use of Self
.
Here's the section that addresses this:
https://github.com/LoganWright/Genome#inheritance
The other option is to move to a struct.
Let me know if you don't get it with that, and we can walk through it together 👍