I added this code to my ViewController class under (#pragma mark - UITableViewDelegate Methods)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"selected cell = %@", cell.textLabel.text);
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
NSLog(@"row = %ld", indexPath.row);
}
I just want to display the text that I select but it's not working. Any ideas what I'm doing wrong?
Full code is here: IOS 8 Objective-C Search bar and Table view Using Google Autocomplete
Thanks for the help!
EDIT: I also added the following code:
viewDidLoad method (ViewController.m)
_tableView.allowsSelectionDuringEditing = YES;
_tableView.delegate = self;
_tableView.dataSource = self;
changed ViewController.h code from
@interface ViewController : UIViewController
to
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>