All Projects → sgr-ksmt → FirstAppearing

sgr-ksmt / FirstAppearing

Licence: MIT license
[Swift] Helper Protocol-Extension for UIViewController's viewWillAppear/viewDidAppear.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Note: This framework no longer maintained (not available in Swift 3). Use Once instead. 🙇

FirstAppearing

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

Carthage Compatible Version License Platform

🎉Features

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

✏️How to use

  • Adapt 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

With Carthage

  • Just add the following line to your Cartfile:
github "sgr-ksmt/FirstAppearing"
  • Run carthage update on Terminal.
  • Add the framework as described. Details: Carthage README

With CocoaPods

Just add the following line to your Podfile:

pod 'FirstAppearing'
  • Run pod install on Terminal.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].