UIViewController

  • SwifterSwift: Check if ViewController is onscreen and not hidden.

    Declaration

    Swift

    public var isVisible: Bool
  • SwifterSwift: Assign as listener to notification.

    Declaration

    Swift

    public func addNotificationObserver(name: Notification.Name, selector: Selector)

    Parameters

    name

    notification name.

    selector

    selector to run with notified.

  • SwifterSwift: Unassign as listener to notification.

    Declaration

    Swift

    public func removeNotificationObserver(name: Notification.Name)

    Parameters

    name

    notification name.

  • SwifterSwift: Unassign as listener from all notifications.

    Declaration

    Swift

    public func removeNotificationsObserver()
  • SwifterSwift: Helper method to display an alert on any UIViewController subclass. Uses UIAlertController to show an alert

    Declaration

    Swift

    @discardableResult public func showAlert(title: String?, message: String?, buttonTitles: [String]? = nil, highlightedButtonIndex: Int? = nil, completion: ((Int) -> Void)? = nil) -> UIAlertController

    Parameters

    title

    title of the alert

    message

    message/body of the alert

    buttonTitles

    (Optional)list of button titles for the alert. Default button i.e OK will be shown if this paramter is nil

    highlightedButtonIndex

    (Optional) index of the button from buttonTitles that should be highlighted. If this parameter is nil no button will be highlighted

    completion

    (Optional) completion block to be invoked when any one of the buttons is tapped. It passes the index of the tapped button as an argument

    Return Value

    UIAlertController object (discardable).