Search code examples
iosxcode4storyboard

How to get custom cell data when row is tapped?


I have a custom table view cell with 3 fields in it. I need to get the data in one of those fields to use in a SQLite query.

I've looked at cellForRowAtIndexPath, but don't see how to address the particular cell I want (it was defined with an IBOutlet, so it has a name) and get it's value.


Solution

  • I figured it out... here is the code:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
    
        SingletonClass *shareInstance= [SingletonClass sharedInstance];
        sArray *sa = [shareInstance.listOfSites objectAtIndex:indexPath.row];  //  (rows are zero based)
        NSString *labelContent = sa.sSiteID;  //  labelContent = site_id
    
        //  get list of sites based on selected row
        slSQLite *dbCode = [[slSQLite alloc] init];
        [dbCode getListOfSites:labelContent];  //  labelContent is used to build query
    }