Created
February 8, 2019 11:44
-
-
Save rtking1993/a3bec3cc9c1a868bcd5c8482cad5f78e 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
// MARK: LoginViewController | |
class LoginViewController: UIViewController, AuthenticationSessionDelegate { | |
func login(with username: String, | |
password: String) { | |
let authenticationSession = AuthenticationSession() | |
authenticationSession.delegate = self | |
authenticationSession.performLogin(with: username, | |
password: password) | |
} | |
// MARK: AuthenticationSessionDelegate Methods | |
func authenticationSession(_ authenticationSession: AuthenticationSession, didLoginWith userIdentifier: String) { | |
// Handle the login with userIdentifier | |
} | |
} | |
// MARK: AuthenticationSessionDelegate | |
protocol AuthenticationSessionDelegate: class { | |
func authenticationSession(_ authenticationSession: AuthenticationSession, didLoginWith userIdentifier: String) | |
} | |
// MARK: AuthenticationSession | |
class AuthenticationSession { | |
var delegate: AuthenticationSessionDelegate? | |
func performLogin(with username: String, | |
password: String) { | |
let userIdentifier = "12345" //Service.login(username, password) | |
delegate?.authenticationSession(self, didLoginWith: userIdentifier) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment