Reputation: 48
I have a TableView with a prototype cell, in this prototype cell I have a text field. Well, what I need is to get a information from this text field when it changes. I need to do that to feed a object.
How can I do that ?
Upvotes: 0
Views: 80
Reputation: 2694
You need a custom cell with a public property (IBOutlet) UITextfield. Then you can set your ViewController as the textField's delegate in cellForRowAtIndexPath,
cell.textField.delegate = self;
in this case your ViewController has to implement UITextFieldDelegate protocol.
Upvotes: 0
Reputation: 77631
Short answer - you don't.
Slightly more in depth answer...
The UITableViewCell
is a "view". It is used only to display information to the screen. It is not for storing data in.
In a UITableViewController
(i.e. UITableViewDatasource
and UITableViewDelegate
) you should have an NSArray
(or an NSFetchedResultsController
) that you use to store information in.
Then using the delegate methods you populate the table with that data.
If the data changes then you reload the table to update the cells.
What should never happen is the following...
What should happen is this...
Upvotes: 5