ios - Generic toArray<T> function which can call an init on the Type T -


i have struct called flowercategory shown below:

struct flowercategory  {      var id :int?     var title :string     var imageurl :string    }  extension flowercategory {      init?(node :node) {         // here      } } 

i creating extension on node class convert node typed class array. problem cannot invoke t.init initializer shown below:

extension node {      func toarray<t>() -> [t]? {          guard let nodes = self.nodearray else {             return nil         }          return nodes.flatmap(t.init) // not work     }  } 

is there anyway trying achieve?

update:

enter image description here


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -