EditPlantLevelManager

class EditPlantLevelManager : NSObject

Undocumented

  • The plant object to be edited

    Declaration

    Swift

    unowned var plant: Plant
  • The plants manager to handle global operations on the plants such as writing changes to disk

    Declaration

    Swift

    unowned var plantsManager: PlantsManager?
  • A delegate to link the editing manager to the table view controller that owns it.

    Declaration

    Swift

    var parentTableViewDelegate: ParentTableViewDelegate?
  • The various levels of the plant that can be changed

    See more

    Declaration

    Swift

    enum PlantLevel : String
  • The plant level that is being operated on.

    When it is set, this causes a reset for the manager by having it set the allItems array, the plantItems array, and making a new editing cell.

    Declaration

    Swift

    var plantLevel: EditPlantLevelManager.PlantLevel? { get set }
  • All of the cases for the plant level being edited.

    For example, if plantLevel is PlantLevel.dormantSeason, then allCases holds all of the possible values in the Season enum.

    Declaration

    Swift

    var allCases: [Any]?
  • All of the raw values (as Strings) from the cases in allCases.

    For example, if plantLevel is PlantLevel.dormantSeason, then allItems holds all of the possible raw values in the Season enum.

    Declaration

    Swift

    var allItems: [String]?
  • The values from allItems that are selected for the plant object.

    For example, if plantLevel is PlantLevel.dormantSeason, then plantItemsholds the raw values of the cases of the Season enum for which the plant is dormant. The values will be already selected in the segmented controller.

    Declaration

    Swift

    var plantItems: [String]?
  • The detail label of the cell with the plant’s information that is being edited.

    By keeping it within this manager, it can be live-updated as a new value is selected in the editing row.

    Declaration

    Swift

    var detailLabelOfCellBeingEdited: UILabel?
  • The index in the parent table view that is being edited. This is mainly used by the owner view controller for tracking the cell being edited.

    Declaration

    Swift

    var editingRowIndex: Int?
  • The actual cell that is presented to the user with the various options to select from the change the plant’s information.

    Declaration

    Swift

    var editingCell: EditingTableViewCell?
  • Undocumented

    Declaration

    Swift

    init(plant: Plant, plantLevel: PlantLevel)
  • Set the allItems and allCases arrays depending on the plantLevel.

    Declaration

    Swift

    private func setAllItems()
  • Set the plantItems array depending on the plantLevel and current value(s) set for the plant.

    Declaration

    Swift

    private func setPlantItems()
  • Prepare the cell to present to the user with a segmented controller containing the options to be selected.

    Declaration

    Swift

    private func setupEditingCell()
  • Prepare the segmented controller for the editing cell.

    Declaration

    Swift

    private func setUpEditingCellSegmentedControllerItems()
  • Get the indeces to be set for the segmented controller in the editing cell

    Declaration

    Swift

    private func indexesToSelect(forSegmentedController segmentedController: MultiSelectSegmentedControl) -> IndexSet

    Parameters

    segmentedController

    The segmented controller to be set (it is not actually mutated in this method).

    Return Value

    The IndexSet to assign to the segmented controller.

  • The method called when the segmented controller changes.

    The plant object is updated based on the selected cells in the segmented controller. Afterwards, the plantsManager is asked to save the plants and the parent table view controller is notified.

    Declaration

    Swift

    func multiSelect(_ multiSelectSegmentedControl: MultiSelectSegmentedControl, didChange value: Bool, at index: Int)

    Parameters

    multiSelectSegmentedControl

    The segmented controller that has a change in value.

    value

    A Bool for if the value did change.

    index

    The index of the change.