Advertisement
DhruvSaraswat

Pocket FM Round 1 LLD Code

Jul 3rd, 2024
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.06 KB | Software | 0 0
  1. import UIKit
  2. import Foundation
  3.  
  4. // Design login view model whch can adopt any type of login (login via Facebook, Gmail, Apple etc)
  5. // We will have 3 different view controllers - and we need only 1 single view model for all 3
  6.  
  7. protocol LoginManager {
  8.     func signIn()
  9.     func signOut()
  10. }
  11.  
  12. final class FacebookLoginManager: LoginManager {
  13.     func signIn() {
  14.     }
  15.    
  16.     func signOut() {
  17.     }
  18. }
  19.  
  20. final class GmailLoginManager: LoginManager {
  21.     func signIn() {
  22.     }
  23.  
  24.     func signOut() {
  25.     }
  26. }
  27.  
  28. final class AppleLoginManager: LoginManager {
  29.     func signIn() {
  30.     }
  31.  
  32.     func signOut() {
  33.     }
  34. }
  35.  
  36. final class LoginViewModel {
  37.     private var loginManager: LoginManager
  38.    
  39.     init(loginManager: LoginManager) {
  40.         self.loginManager = loginManager
  41.     }
  42.    
  43.     func signIn() {
  44.         loginManager.signIn()
  45.     }
  46.    
  47.     func signOut() {
  48.         loginManager.signOut()
  49.     }
  50. }
  51.  
  52. func printFunc() {
  53.     defer {
  54.         print("A")
  55.     }
  56.     defer {
  57.         print("B")
  58.     }
  59.     defer {
  60.         print("C")
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement