Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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)
- }
- }
Add Comment
Please, Sign In to add comment