FirstAppearing 0.1.0

FirstAppearing 0.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2016
SPMSupports SPM

Maintained by sgr-ksmt.



  • By
  • Suguru Kishimoto

FirstAppearing

Helper Protocol-Extension for UIViewController’s viewWillAppear/viewDidAppear.

:tada:Features

  • Just once do process in viewWillAppear/viewDidAppear
  • Safety called. (If you use viewWillAppearOnce in viewDidLoad, this process will not be working.)

:pencil2:How to use

  • Adopt FirstAppearing protocol.
  • Use viewWillAppearOnce in viewWillAppear or
    Use viewDidAppearOnce in viewDidAppear.
class SomeViewController: UIViewControlelr, FirstAppearing {
    override func viewDidLoad() {
        super.viewDidLoad()
        viewWillAppearOnce() {
            print("Wahahaha!") // not working!!
        }
    }

    override func viewWillAppear(animated: Bool) {
        self.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed
        super.viewWillAppear(animated)
        viewWillAppearOnce() {
            // do something
            print("Once call,",__FUNTION__)
        }
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        viewDidAppearOnce() {
            // do something
            print("Once call,",__FUNTION__)
        }
    }
}

Requirements

  • iOS 8.0+
  • Xcode 7.0+(Swift 2+)

Installation and Setup