A usermanager written in swift 3.0 saves you from hassle of saving your active user session.
UserManager.setCurrentUser(model)
let profileFromServer = [ "firstName" : "Zeeshan", "userName" : "xeieshan", "lastName" : "Haider", "id" : 1, "email" : "[email protected]" ] as [String : Any]
let profileModel : MOProfile = MOProfile(profileFromServer as Dictionary<String, AnyObject>) UserManager.setCurrentUser(newCurrentUser: profileModel)
debugPrint((UserManager.currentUser?.firstName)! as String)
UserManager.logOutUserAndClearToken()
if UserManager.currentUser != nil { // Take to App } else { // Take to Login // After Login save user }