Q:

How to get all UITextField values in UITableView?

I'm working with Core Data. I have a Core Data entity named Users. I'm listing Users in a UITableView. Multi-selection is enabled for UITableView. UITableViewCell subclass includes a UILable for username and UITextField for price. Also, I have a Core Data entity named Expenses.
The thing I'm trying to do is: I will enter prices for users, and will save to Expenses with the info of the user and price. For example:

I have 10 users listed in UITableView. (DONE)
All cells have UITextField for price. (DONE)
I enter prices in UITextField for 5 users which I selected. (DONE)
Get the info which includes userUID and price from selected cells. (FAIL)
Save userUID and price to Expenses with doneButton.

Here's what my Core Data entities look like:
Users:
@NSManaged public var userName: String
@NSManaged public var userUID: String

Expenses:
@NSManaged public var userUID: String
@NSManaged public var price: Int

class viewController : UIViewController, UITableViewDelegate,UITableViewDataSource {

 @IBOutlet weak var tableView: UITableView!

 var fetchedResultsController : 
    NSFetchedResultsController<Users>!

  override func viewDidLoad() {
        super.viewDidLoad()
        tableView.allowsMultipleSelection = true 
  }

  override func viewWillAppear(_ animated: Bool) {

        fetchUsers() 

  }

  func fetchUsers() {
     ...... // FETCHING USERS FROM COREDATA
     tableView.reloadData()
  }

  @IBAction func doneButton(_ sender: UIBarButtonItem) {
     // ????????????
  }

 func numberOfSections(in tableView: UITableView) -> Int {
        guard let fetchRes  =  fetchedResultsController , let sections 
    = fetchRes.sections else {
            return 0
        }
        return sections.count
    }

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

        guard let fetchRes  =  fetchedResultsController , let 
 sectionInfo = fetchRes.sections?[section] else {
            return 0
        }
        return sectionInfo.numberOfObjects
    }

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: 
 IndexPath) -> UITableViewCell { 

        let cell = tableView.dequeueReusableCell(withIdentifier: 
          "Cell", for: indexPath) as! CustomCell

        let User = fetchedResultsController.object(at: indexPath)

        cell.lblUserName.text = User.userName

    return cell
 }

}

class CustomCell : UITableViewCell {

    @IBOutlet weak var lblUserName: UILabel!
    @IBOutlet weak var txtPrice: UITextField!

}

The thing I want to do is, get userUID and price from UITextField from selected cells.

A:

The thing is you shouldn't use UITableViewCell as data storage because TableView can release them from memory if they are not present on the screen. 
One option has data storage in ViewController and set a reference to it to cells. UITextField in this cell than set value directly into this data storage.
So with a done button, you can just read values from data storage.

