Created
December 3, 2017 21:28
-
-
Save LucianoPAlmeida/d8dba3da70b60f811aa8a125bcf467ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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