Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import Foundation
- // Design login view model whch can adopt any type of login (login via Facebook, Gmail, Apple etc)
- // We will have 3 different view controllers - and we need only 1 single view model for all 3
- protocol LoginManager {
- func signIn()
- func signOut()
- }
- final class FacebookLoginManager: LoginManager {
- func signIn() {
- }
- func signOut() {
- }
- }
- final class GmailLoginManager: LoginManager {
- func signIn() {
- }
- func signOut() {
- }
- }
- final class AppleLoginManager: LoginManager {
- func signIn() {
- }
- func signOut() {
- }
- }
- final class LoginViewModel {
- private var loginManager: LoginManager
- init(loginManager: LoginManager) {
- self.loginManager = loginManager
- }
- func signIn() {
- loginManager.signIn()
- }
- func signOut() {
- loginManager.signOut()
- }
- }
- func printFunc() {
- defer {
- print("A")
- }
- defer {
- print("B")
- }
- defer {
- print("C")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement