Swift protocol defining class method returning self -
i had code working in xcode 6 beta stopped working after updating xcode 6.1.
this protocol:
protocol candeserialisefromjson { class func fromjson(json : jsonvalue) -> self }
this implementation:
extension invoice : candeserialisefromjson { class func fromjson(json : jsonvalue) -> self { homecoming invoice() } }
this fails giving error:
'invoice' not convertable 'self'
as said, used work , can't work out why doesn't anymore
self
in protocol requirement implementations of protocol utilize own type. since invoice
type you're adopting protocol in, implementation of fromjson
should have homecoming type of invoice
.
swift protocols
No comments:
Post a Comment