I’m planning an ordering system based on an UITableView for iPad. I’m subclassing UITableViewCell to show different UILabel, UIButton and UITextfield instances in a row.
But I’ve got a question: how to connect UIButton and UITextField instances together to know, which ones belong together?
The easiest idea (and I guess the worst one ;-)) would be to keep everything in a single class to maintain it somehow. But I would like to keep several classes because of the logical split (articles, shopping cart, categories …). But my problem is – how to connect them? When I click the button to add a new item – how do I exactly know that it was the article with number 234233? I know it would be possible to work with a tag – but I need more items in a row that need to be tagged… And to modify them…
I hope someone can help =).
As always, thanks in between!
I usually set up my row subclass so that when I set what needs to be displayed (text,images) I pass in the entire data object to the row and keep a reference to it. Then when a button is clicked I use the row as the target and I will have all the information I need available right there.
After that I call a method in the controller as that’s usually where the action needs to be processed.
In some other cases I pass the indexPath to the row but this has caused me problems later on.