Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. protocol Item {
  2. var identifier: String { get }
  3. var name: String { get set }
  4. }
  5.  
  6. struct SomeItem: Item {
  7. let identifier: String = UUID().uuidString
  8. var name: String = "New Item"
  9. }
  10.  
  11. protocol ItemManager {
  12.  
  13. /// get some objects matching query criteria
  14. func objects(matching query: Query) -> [Item]
  15.  
  16. /// get a specific object
  17. func object(withID identifier: String) -> Item?
  18.  
  19. /// commit these to disk.
  20. func save(_ object: Item) throws
  21.  
  22. /// deletes the objects from disk.
  23. func delete(_ objects: [Item])
  24.  
  25. /// creates a new object but does not save it.
  26. func create() -> Item
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement