Tuesday, 15 January 2013

reflection - Create instance dynamically from type (to use in generics) -



reflection - Create instance dynamically from type (to use in generics) -

how create class dynamically instance?

i have function uses generics generate data. lets pass complex type

generatedata() [classa] //usage

func generatedata<t>() ->[t] //declaration

so lets have instance of classa or classb. how generate list them during runtime?

//doesn't work nor .class allow classtype = instanceofclassa.dynamictype allow mygeneratedainstances = generatedata() [classtype]

if want parse object dictionary , dictionary object, seek class: https://github.com/evermeer/evcloudkitdao/blob/master/appmessage/appmessage/cloudkit/evreflection.swift

generics reflection swift

No comments:

Post a Comment