Hello my problem is the following I have several cells created, with their respective titles each, but when I try to add more iten to each cell I get error, or does not present the value in the cell this is an example of the app
The question is where this example calculation area is the cell to how I can add another cell within that area without affecting the others, I'm using the code
/
// ViewControllerGeometry.swift
// calculos2
//
// Created by Liantony Pozo on 7/19/17.
// Copyright © 2017 Liantony Pozo. All rights reserved.
//
import UIKit
class ViewControllerGeometry: UIViewController , UITableViewDelegate , UITableViewDataSource {
var tableArray : [Problems] = []
var tableArrayGeometryProblem : [Problemp] = []
var tableArrayProblemsSecond : [ProblemsSecond] = []
var segueIdentifiers = ["prueba" , "B", "C"]
override func viewDidLoad() {
super.viewDidLoad()
let geometryproblem = Problems (name : "a")
tableArray.append(geometryproblem)
let geometryProblemSecond = ProblemsSecond(nameSecond: "b")
tableArrayProblemsSecond.append(geometryProblemSecond)
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 tableArrayProblemsSecond.count
case 2:
return tableArrayGeometryProblem.count
default:
return 0
}
//return tableArrayGeometryProblem.count
}
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]
let geometryProblemSecond = tableArrayProblemsSecond [indexPath.row]
switch indexPath.section {
case 0 :
if indexPath.row == 0 {
cell.textLabel?.text = geometryproblem.name
}
case 1 :
if indexPath.row == 0 {
cell.textLabel?.text = geometryProblemSecond.nameSecond
}
case 2 :
if indexPath.row == 0 {
cell.textLabel?.text = perimeterProblemCalculation.nameGeometryProblem
}
default:
break
}
return cell
}
/* 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 + indexPath.section], 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
}
}
Sometimes only one value presents me in the cell, the other does not show me or I get an error in the code if someone could guide me in that problem.