KZViewController 1.0.1

KZViewController 1.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Zonily Jame Pesquera.



KZViewController

UIViewController Subclass for refreshing User Interface/Data when there is a logout involved in your app

Table of Contents

Installation

To install KZViewController via cocoapods, simply use the add this in your podfile and then run pod install

pod 'KZViewController'

How to Use

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

Refresh UI/Data

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

On logout

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()

Performing something on 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
}

Performing something if still LoggedIn

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
}