GeneralPlantInformationTableViewController

class GeneralPlantInformationTableViewController : UITableViewController

Table view controller within the LibraryDetailViewController that presents the general information of a plant. The complexity of this view controller is mainly due to the system for editing the plant’s atteributes.

  • The plant object for the general information table view

    Declaration

    Swift

    var plant: Plant!
  • The PlantsManager delegate that handles tasks such as saving the plants if any information is edited

    Declaration

    Swift

    var plantsManager: PlantsManager!
  • Delegate to handle the editing row for collection type information

    Todo

    make private

    Declaration

    Swift

    var editManager: EditPlantLevelManager?
  • Prepares the view controller by setting it as the delegate for the table view and organizing the row editing manager and cell

    Declaration

    Swift

    func setupViewController()
  • Number of sections in the general plant into table view.

    Declaration

    Swift

    override func numberOfSections(in tableView: UITableView) -> Int

    Parameters

    tableView

    standard iOS table view

    Return Value

    the number of sections (1)

  • How many rows for the general plant info table view.

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

    Parameters

    tableView

    standard iOS table view

    section

    which section of the table view (not used)

    Return Value

    the number of rows that will be in the table; this value adjusts depending on whether the edit row is available or not

  • Undocumented

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  • Adds the appropriate information to a cell of the general table view depending on the index.

    Declaration

    Swift

    func addGeneralInformation(toCell cell: inout UITableViewCell, forIndexPathRow row: Int)

    Parameters

    cell

    the cell to add information to

    row

    row number of the cell

  • Undocumented

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
  • Get the plent level selected for the editing manager

    This is only applicable for cells that need to be edited by the edit manager, ie. not the scientific name nor the common name.

    Declaration

    Swift

    func getPlantLevel(forRow row: Int) -> EditPlantLevelManager.PlantLevel?

    Parameters

    row

    which row was tapped to edit

    Return Value

    the plant level to be edited

  • Undocumented

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
  • Undocumented

    Declaration

    Swift

    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
  • Reload the table view and save the plants data

    Declaration

    Swift

    private func reloadGeneralInfoTableViewAndSavePlants()
  • Undocumented

    See more

    Declaration

    Swift

    enum PlantName
  • Change the plant’s names using a Alert with a text field

    On completion, the table’s data is reloaded and saved by calling reloadGeneralInfoTableViewAndSavePlants

    Declaration

    Swift

    func getNewName(for plantName: PlantName)

    Parameters

    plantName

    which plant name to edit

  • Called when a value is changed in the segmented controller of the editing cell. It currently does nothing.

    Declaration

    Swift

    func plantLevelDidChange()