Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol HubspotService {
- func fetch() -> [String]
- }
- class TestingHubspotService: HubspotService {
- static let shared = TestingHubspotService()
- private init() {}
- func fetch() -> [String] {
- // Mock data
- return ["Testing", "One"]
- }
- }
- class ProductionHubspotService: HubspotService {
- static let shared = ProductionHubspotService()
- private init() {}
- func fetch() -> [String] {
- // TODO: return results from network
- fatalError()
- }
- }
- class ContactsViewController: UIViewController {
- // MARK: - Stored Properties
- lazy var hubspotService: HubspotService = ProductionHubspotService.shared
- func reload() {
- let results = hubspotService.fetch()
- print(results)
- }
- }
Add Comment
Please, Sign In to add comment