Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. GenericObject: Object
  2.  
  3. Sale: Generic Object // This class includes a primary key called "id"
  4.  
  5. override func newItem<T:GenericObject>(ofType itemType: T.Type) -> T {
  6. let dictionary = self.getDictionary()
  7. let newItem = T.init()
  8. newItem.updateWithDictionary(dict: dictionary)
  9. print("Type: (type(of: newItem)) - Object: (newItem)")
  10. return newItem
  11. }
  12.  
  13. let newObject = object.newItem(ofType: Sale.self)
  14. self.realm.add(newObject, update: true)
  15.  
  16. Type: Sale - Object: Sale { ....
  17.  
  18. Type: Sale - Object: GenericObject { ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement