Skip to content

Instantly share code, notes, and snippets.

@catalinaturlea
Last active September 25, 2019 19:16
Show Gist options
  • Save catalinaturlea/5c46957fba7551839eb52099f02126ce to your computer and use it in GitHub Desktop.
Save catalinaturlea/5c46957fba7551839eb52099f02126ce to your computer and use it in GitHub Desktop.
First changes
class ViewController: UIViewController {
var userService: UserServiceInterface = UserService.shared
func login(email: String, password: String, completion: ((Bool) -> Void)) {
// ....
userService.login(email, password, completion: { (success, error) in
if success {
completion(true)
}
completion(false)
})
}
}
// And make the Service implement the interface
protocol UserServiceInterface {
func login(email: String, password: String, completion: (Bool, Error?))
}
class UserService: UserServiceInterface {
// ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment