I have a UIButton that is created inside of each table cell. I want to hook up a touch event like so:
[imageButton addTarget:self
action:@selector(startVote:)
forControlEvents:UIControlEventTouchUpInside];
I want to pass data about the current row (the id of the object for that row) to the startVote method. Is there a method that I am missing to do this or am I breaking some best practice. This seems like a very normal thing to do?
I assume you have some sort of
NSArraywith the data that gets passed on to the buttons incellForRowAtIndexPath.Try this in
startVote:EDIT:
If for some reason the row is not selected, you can assign a unique
tagto every button upon creation and then:Maybe you would do some sort of operation with the
tagso it can be used as an index (I add a certain amount to everytagso it will not conflict with “automatic” tagging used by the OS.