I am new to IOS development. I am working on an app in which I have few rows and a button in front of each row. In the cellForRowAtIndexPath I have created a function called buttonPressed() and in that function I want to get the data only corresponding to the button I click. Can you help me with this?
Here’s what I am doing.
-(void) buttonPressed: (id) sender withEvent: (UIEvent *) event
{
UITouch *touch= [[event allTouched] anyObject];
CGPoint location = [touch locationInView: self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
trackedUser = [searchResult obectAtIndex:indexPath.row];
}
trackedUser is the object of a class which contains the details of a user like his name, id etc. And SearchResult is an array which displays the list of usernames (on searching in the search bar) in the table view controller.
Modify your cellForRowAtIndexPath-Adding button to cell code like below
Then modify your buttonPressed method as below