Guest User

Untitled

a guest
Apr 26th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. protocol HubspotService {
  2. func fetch() -> [String]
  3. }
  4.  
  5. class TestingHubspotService: HubspotService {
  6. static let shared = TestingHubspotService()
  7. private init() {}
  8.  
  9. func fetch() -> [String] {
  10. // Mock data
  11. return ["Testing", "One"]
  12. }
  13. }
  14.  
  15.  
  16. class ProductionHubspotService: HubspotService {
  17. static let shared = ProductionHubspotService()
  18. private init() {}
  19.  
  20. func fetch() -> [String] {
  21. // TODO: return results from network
  22. fatalError()
  23. }
  24. }
  25.  
  26. class ContactsViewController: UIViewController {
  27.  
  28. // MARK: - Stored Properties
  29.  
  30. lazy var hubspotService: HubspotService = ProductionHubspotService.shared
  31.  
  32. func reload() {
  33. let results = hubspotService.fetch()
  34. print(results)
  35. }
  36. }
Add Comment
Please, Sign In to add comment