swift - Unable to call type method on class conforming to protocol -
my code simple.
my protocol:
protocol baseentity { class func getinstance(sourceobject: [nsobject : anyobject], context: anyobject!) -> baseentity init() }
then in class have method:
private func convertjsondictionaryintomodel(jsondictionary : [nsobject : anyobject], mapclass: baseentity.type) -> baseentity { let object = mapclass.getinstance(jsondictionary, context: nil) return object }
i got compiler error on first line reads "accessing members of protocol type value baseentity.type unimplemented"
as far can tell, possible in swift.
i encountered too! means swift programming language doesn't support class methods inside of protocols... yet. workaround seems depend on specific situation , there's no "you should instead". if has better solution, please share!
this case class variables, there hacky workaround that.
Comments
Post a Comment