Tuesday, November 10, 2026
HomeiOS Developmentios - cowl methodology by Unit check?

ios – cowl methodology by Unit check?

[ad_1]

I’ve a way like this. cowl it with a Unit check?
The strategy returns void and comprises solely a swap that handles the totally different situation.

 func getSession(with mode: LaunchMode, completion: ((UserSessionLaunchInfo) -> Void)? = nil) {
        print(#operate)
        self.completion = completion
        
        if let session = getStoredUserSession() {
            swap mode {
            case .login:
                print("login")
                LocalStorage.deleteDatabase()
                UserDefaults.dataTimestamp = nil
                syncSessions(currentSession: session)
                return
            case .signup:
                print("signup")
                LocalStorage.deleteDatabase()
                UserDefaults.dataTimestamp = nil
                syncSessions(currentSession: session)
            case .logout:
                print("logout")
                LocalStorage.deleteDatabase()
                createSessionFromScratch()
                UserDefaults.dataTimestamp = nil
                return
            default:
                if Date.getCurrentDate() == UserDefaults.dataTimestamp || ReachabilityService.shared.currentStatus != .happy {
                    completion?(UserSessionLaunchInfo(userSession: session))
                } else {
                    postSession(currentSession: session)
                }
                return
            }
        } else {
            createSessionFromScratch()
        }
    }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments