TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Feb 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Zonily Jame Pesquera.
UIViewController Subclass for refreshing User Interface/Data when there is a logout involved in your app
To install KZViewController via cocoapods, simply use the add this in your podfile and then run pod install
pod 'KZViewController'
Simply Subclass your UIViewController with KZViewController instead if using UIViewController.
class SomeViewController: KZRefreshViewController {
}
On your AppDelegate if you want to see logs of KZViewController’s userDidLogout()
, userStillLoggedIn()
, loggedOutNotification
, viewDidRefresh()
and viewWillRefresh()
just add this snippet inside didFinishLaunchingWithOptions
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// this automatically defaults to false if not set
KZVCHelper.sharedInstance.showLogs = true
return true
}
KZViewController is a UIViewController subclass
Inside your SomeViewController
class simply override the refresh()
function like this
// this function is called on viewWillAppear
override func viewWillRefresh() {
super.viewWillRefresh()
// do refresh of variables and user interface here
}
// this function is called by viewWillRefresh
override func viewDidRefresh() {
super.viewDidRefresh()
// do something after refresh
}
Quick note these functions are only called once and you’d need to call KZVCHelper.logOut() again to refresh all UIViewControllers
sublcassed with KZRefreshViewController
Simply call this function when logging out so that viewWillRefresh()
will be called on viewWillAppear()
of your SomeViewController
class
//inside some logout block
KZVCHelper.logOut()
You can do some other stuff if the user has logged out by overriding userDidLogout()
function
override func userDidLogout() {
super.userDidLogout()
//do something if user has logout
}
You can do some other stuff if the user is still LoggedIn out by overriding userStillLoggedIn()
function
override func userStillLoggedIn() {
super.userStillLoggedIn()
//do something if still loggedIn
}