Problem with UITableView and passing from one view controller to another

Hello friends I am new in language may be the answer simple sea but I do not find the form and I go to the forum to see if I can explain a way please the problem is the following I’m trying to a taleView with contain divisors and in those divisions different things and when you touch one it would send to another view ie a segue, the problem is that when they touch always send to the same view .It connects it uses the same segue

import UIKit
class ViewControllerGeometry: UIViewController , UITableViewDelegate , UITableViewDataSource {
  var tableArray : [Problems] = []
  var tableArrayGeometryProblem : [Problemp] = []

  var segueIdentifiers = ["prueba" , "B", "C"]



  override func viewDidLoad() {
  super.viewDidLoad()
  let geometryproblem = Problems (name : "a")
  tableArray.append(geometryproblem)


  let perimeterProblem = Problemp(nameGeometryProblem: "c")
  tableArrayGeometryProblem.append(perimeterProblem)

  // Do any additional setup after loading the view.
  }
  override func didReceiveMemoryWarning() {
  super.didReceiveMemoryWarning()
  // Dispose of any resources that can be recreated.
  }


  func numberOfSections(in tableView: UITableView) -> Int {
  return 4
  }

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



  switch section{
  case 0:
  return tableArray.count

  case 1 :

  return tableArrayGeometryProblem.count



  default:
  return 0
  }


  }




  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  let cell = tableView.dequeueReusableCell(withIdentifier: "cellGeometryproblem")! as UITableViewCell


  let geometryproblem = tableArray [indexPath.row]

  let perimeterProblemCalculation = tableArrayGeometryProblem [indexPath.row]
  switch indexPath.section {

  case 0:

  cell.textLabel?.text = geometryproblem.name
  case 1 :
  cell.textLabel?.text = perimeterProblemCalculation.nameGeometryProblem


  default:
  return cell
  }




  return cell
  }
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  performSegue(withIdentifier: segueIdentifiers[indexPath.row], sender: self)
  }

  func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
  var title = ""


  switch section {
  case 0:
  title = "Area calculation "
  case 1 :

  title = "Perimeter calculation "

  case 2 :

  title = "Sen theorem "

  case 3 :

  title = "Inside angles of the triangle "



  default:
  break
  }
  return title
  }

}

Powered by WPeMatico

You may also like...

Comments are closed.