Note: This framework no longer maintained (not available in Swift 3). Use Once instead. 🙇
FirstAppearing
Helper Protocol-Extension for UIViewController's viewWillAppear/viewDidAppear.
🎉 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.