ios - Swift generic object factory won't use child class initializer -


i'm trying make factory take generic type , return array of given type. however, when try using t.self() initializes superclass initializer (initializable in case). but, have subclass want initialized.

class initializable {     let object: pfobject     init(_ object: pfobject) {         self.object = object     } }  class objectfactory {     class func create<t: initializable>(objects: [anyobject]?) -> [t] {         if let objects = objects as? [pfobject] {             return objects.map {object in                 t.self(object)             }         }         println("unable create objects")         return []     } } 

then when try

let subclasses: [subclass] = objectfactory.create([subclass])

then subclasses ends being array of initializable opposed subclass. doing wrong?


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -