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

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -