Here is my problem:
I have an array of model class(Let’s say, ‘addressModel’ with fields address, street and city.). Now i have a custom cell with three UITextFields for the three fields in the model class. Once the user ends editin, i want to (validate &) add the data in the particular textfield to the respective model object. (Ex: user ended editing addressTextField, then addressModel.address = addressTextField.text).
How can we identify the textfield that the user selected and the indexPath.row? In my case i need to know both? Any help?
Thank you.
If your view controller implements the
UITextFieldDelegateprotocol, you can receive thetextFieldDidEndEditingmethod call. In there, you can get the tag of the field that the user was just editing. When creating your cells you can specify some kind of integer tag scheme so that you can reverse engineer what section, row, and specific field the user was actually editing at the time. You could do something like:Assuming you don’t have more than 100 textFields per row, or 100 rows per section, this particular scheme should work.