views:

92

answers:

1

I have created a custom uitablecell which contains several values. When the user selects a row, I want to be able to select that row's content for one of the values in the custom uitablecell. If the cell looks like this:

ba_type   varchar2(20)    P
source    varchar2(20)    P
row_qual  varhcar2(20)

If the user has selected the 'source varchar2(20) P' row, I want to be able to grab the value of 'source' out for my next query.

thx, wes

+1  A: 

Strictly speaking, you've created a tableview cell that displays several values. Sitting in memory somewhere behind that is an array that contains the actual data. That's how MVC architecture works.

Ideally, you have some data structure in memory that corresponds to the cells. If you had an NSMutableArray in memory, you could retrieve the value by doing

// assumes one section in the table view
    NSString* sourceForNextQuery = [dataSourceUsedToPopulate objectAtIndex: indexPath.row];  

inside didSelectRowAtIndex

If you insist on retrieving the text from the label in the table view cell, when you create the label that contains it, add a tag (mySourceLabel.tag = 999). Then find that tag again by using searching for the tag, the get the text (UILabel.text)

But really, you want to separate the presentation of the data from the underlying model, and have the controller contain the data.

justin