![Screenshot of this control](https://www.cocoacontrols.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1lxIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--294a702c0ea6f0e7ba2a9315dbe2dfa64e622e6b/Screen_Shot_2017-02-15_at_12.06.18_PM.png)
1 image
Author
Description
A usermanager written in swift 3.0 saves you from hassle of saving your active user session.
** Call api and give the json to MOProfile to make a model and call 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)
**Now you can use this**
debugPrint((UserManager.currentUser?.firstName)! as String)
**To logout simply call**
UserManager.logOutUserAndClearToken()
**If you want to see if your user is logged (for autologin)**
if UserManager.currentUser != nil {
// Take to App
} else {
// Take to Login
}