Skip to content

A usermanager written in swift saves you from hassle of saving your active user session.

License

Notifications You must be signed in to change notification settings

xeieshan/SwiftUserManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

SwiftUserManager

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)

You can access properties of your loggedin user like

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 // After Login save user }

About

A usermanager written in swift saves you from hassle of saving your active user session.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages