Guest User

Untitled

a guest
Feb 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. protocol Calculable {
  2. // The calc logic you were going to have in SessionHelper
  3. func calc()
  4. }
  5.  
  6. protocol Timeable {
  7. // The same timeElapsed property you had before
  8. var timeElapsed: TimeInterval { get }
  9. }
  10.  
  11. class Session {
  12. var start: Date
  13. var end: Date
  14.  
  15. init() {
  16. self.start = Date()
  17. self.end = Date()
  18. }
  19. }
  20.  
  21. // Mark: - Timeable Conformance -
  22. extension Session: Timeable {
  23. var timeElapsed: TimeInterval {
  24. return calcSomething(start, end, pauses, resumes)
  25. }
  26. }
  27.  
  28. // MARK: - Calculable Conformance
  29. extension Session: Calculable {
  30. func calc() {
  31. // Perform the logic for calculating right in here using timeElapsed computed property
  32. }
  33. }
Add Comment
Please, Sign In to add comment