dimanche 24 juin 2018

how to clone object model swift

I want using Mirror to add to the parent class without having to add a clone of the child's class

Do you think this is possible?

base class :

class BaseModel {

 func clone() -> BaseModel {

          let mirror = Mirror(reflection : self)
           for (lable , value) in mirror.children {

             }
          return ...
   }
}

subclass :

class UserModel:BaseModel {

   var name:String!
   var family:String!

}

use sample :

 let cloneModel = self.userModel.clone()





Aucun commentaire:

Enregistrer un commentaire