I had code that was working in XCode 6 beta but stopped working recently after updating to xcode 6.1.
This is my protocol:
protocol CanDeserialiseFromJson {
class func FromJson(json : JSONValue) -> Self
}
This is implementation:
extension Invoice : CanDeserialiseFromJson {
class func FromJson(json : JSONValue) -> Self {
return Invoice()
}
}
This fails giving error:
'Invoice' is not convertable to 'Self'
As I said, this used to work and I can't work out why it doesn't anymore
Self
in a protocol is a requirement that implementations of the protocol use their own type. Since Invoice
is the type you're adopting the protocol in, your implementation of FromJson
should have a return type of Invoice
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments