OptionSelector

public protocol OptionSelector

Interface for selecting objects based on index or reference.

  • Type of the options to be able to select.

    Declaration

    Swift

    associatedtype OptionType : Equatable
  • Array of options that can be selected.

    Declaration

    Swift

    var options: [OptionType] { get }
  • subscript(_:) Default implementation

    Shortcut to get the item at the given index in the array of options.

    Default Implementation

    Declaration

    Swift

    subscript(index: Int) -> OptionType { get }

    Parameters

    index

    Index of element to return. Must be within array bounds.

  • Select the given index in the options.

    Declaration

    Swift

    func select(index: Int)
  • Select the option in the options array.

    Based on the OptionTypes Equatable implementation.

    Declaration

    Swift

    func select(option: OptionType)

    Parameters

    option

    Option to select

  • Deselect the given index in the options.

    Declaration

    Swift

    func deselect(index: Int)
  • Deelect the option in the options array.

    Based on the OptionTypes Equatable implementation.

    Declaration

    Swift

    func deselect(option: OptionType)

    Parameters

    option

    Option to deselect

  • toggle(index:) Default implementation

    Toggles the selected state of the given index in the options.

    Default Implementation

    Based on implementation of isSelected:index, deselect:index, andselect:index.

    If isSelected:index, then deselect:index is called, otherwise select:index is called.

    Declaration

    Swift

    func toggle(index: Int)
  • toggle(option:) Default implementation

    Toggle the option in the array.

    Based on the OptionTypes Equatable implementation.

    Default Implementation

    Based on implementation of isSelected:option, deselect:option, andselect:option.

    If isSelected:option, then deselect:option is called, otherwise select:option is called.

    Declaration

    Swift

    func toggle(option: OptionType)

    Parameters

    option

    Option to toggle

  • Is the given index selected?

    Declaration

    Swift

    func isSelected(index: Int) -> Bool
  • Is the given option selected?

    Declaration

    Swift

    func isSelected(option: OptionType) -> Bool