Latest 1.0.1
Homepage https://github.com/kuyazee/KZViewController
License MIT
Platforms ios 8.0, requires ARC
Authors

Twitter
Github
Cocoapods

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
}

Latest podspec

{
    "name": "KZViewController",
    "version": "1.0.1",
    "summary": "UIViewController Subclass",
    "homepage": "https://github.com/kuyazee/KZViewController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Zonily Jame Pesquera": "[email protected]"
    },
    "social_media_url": "http://twitter.com/kuyazee",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/kuyazee/KZViewController.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "KZViewController",
        "KZViewController/**/*.{h,swift}"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This