Classes

The following classes are available globally.

  • Push/pull views when the keyboard appears and disappears.

    In your UIViewController, add a KeyboardManager property:

       var kb: KeyboardManager?
    

    In viewWillAppear(_:), initialize it and use the according method to subscribe to the show and hide notifications:

       override func viewWillAppear(_ animated: Bool) {
           super.viewWillAppear(animated)
    
           kb = KeyboardManager(viewsToPushUp: [textField, button])
           kb?.pushViewsUpWhenKeyboardWillShow()
           kb?.pullViewsDownWhenKeyboardWillHide()
       }
    

    Although not necessary anymore, if you want to stop listening to the notifications, you can call kb?.stopListeningToKeyboardNotifications() within viewWillDisappear(_:) for example.

    See more

    Declaration

    Swift

    public class KeyboardManager
  • A class used to run a function only once.

    Example:

       let ur = UniqueRunner()
       var result = ur.runOnce(addNumbers(2, 2))
       result = ur.runOnce(addNumbers(5, 5))
       result = ur.runOnce(addNumbers(10, 10))
    
       result == 4 // true
    
    See more

    Declaration

    Swift

    public class UniqueRunner