Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GenericObject: Object
- Sale: Generic Object // This class includes a primary key called "id"
- override func newItem<T:GenericObject>(ofType itemType: T.Type) -> T {
- let dictionary = self.getDictionary()
- let newItem = T.init()
- newItem.updateWithDictionary(dict: dictionary)
- print("Type: (type(of: newItem)) - Object: (newItem)")
- return newItem
- }
- let newObject = object.newItem(ofType: Sale.self)
- self.realm.add(newObject, update: true)
- Type: Sale - Object: Sale { ....
- Type: Sale - Object: GenericObject { ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement