Last active
September 25, 2019 19:16
-
-
Save catalinaturlea/5c46957fba7551839eb52099f02126ce to your computer and use it in GitHub Desktop.
First changes
This file contains hidden or 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
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