I have a Table view, Text field and a update Button. Table view cells count are determined by the user input in the Text field. Table view cells contains only a text field, in which user can enter some data. What I want is, I want to store the user entered data from table view cells into an array when click on that update button. How to do this? What is the best method for this?
This is the code in update button ;
@IBAction func onUpdateButtonClick(sender: AnyObject) {
let tableViewLength = Int(productNumberTxtField.text!)! // TextField data which decides the table view cell count
for index in 0...(tableViewLength-1)
{
let indexPath = NSIndexPath(forRow: index, inSection: 0)
let cell = self.productsTableView.cellForRowAtIndexPath(indexPath) as? ProductCell
if(cell!.productTextField.text != "") { // productTextField is the text field in cell
UserDataController.sharedInstance.saveToProductsCoreData(userName, productName: (cell!.productTextField.text)!)
}
}
}