Skip to content

Instantly share code, notes, and snippets.

@LucianoPAlmeida
Created December 3, 2017 21:28
Show Gist options
  • Save LucianoPAlmeida/d8dba3da70b60f811aa8a125bcf467ef to your computer and use it in GitHub Desktop.
Save LucianoPAlmeida/d8dba3da70b60f811aa8a125bcf467ef to your computer and use it in GitHub Desktop.
import UIKit
class User {
}
enum ResultType<T> {
case success(T)
case error(Error)
}
class DAO {
}
class UserDAO: DAO {
func getAll(completion: @escaping (ResultType<[User]>) -> Void) {
#if TEST
print("Stubbed data from the mocks")
#else
print("Real data from the server")
#endif
}
}
let dao: UserDAO = UserDAO()
dao.getAll(completion: { _ in })
//Depending if the flag is set or not at compile time, the result will be diferent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment