I'm making a very simple app where the user enters the number of people in the first Screen.
In the second screen it generates a number of UITableViewCell
based on the number the user entered in the first screen. The UITableViewCell
have a UITextField
in them and I'm trying to store the data entered in those fields in an array once the user clicks to go to the third screen.
How can I do that?
Thanks in advance!
Edit: I'm using the storyboard.
Here is what the code that calls for the custom UITableViewCell
looks like for my UIViewController
:
func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ var cell: EditingCell = tableView.dequeueReusableCellWithIdentifier("Cell") as EditingCell if indexPath.row % 2 == 0{ cell.backgroundColor = UIColor.purpleColor() } else { cell.backgroundColor = UIColor.orangeColor() } let person = arrayOfPeople[indexPath.row] cell.setCell(person.name) return cell }
Here is what the code for the UITableViewCell
looks like:
class EditingCell: UITableViewCell{ @IBOutlet weak var nameInput: UITextField! override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } func setCell(name:String){ self.nameInput.placeholder = name } }