I have a custom cell in a table View, see below.

I have two textFields txt1 and txt2 in my custom cell, as seen below

How can i access the values i enter in each of the text fields so that i can add the values in to seperate Arrays…
the “Addset” button will increment the no of sections of the grouped table View there by incrementing the one more set.
my table view code is as follows.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID= @"catogoryCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
if(cell==nil)
{
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil];
for(id currentObject in nibObjects)
{
if([currentObject isKindOfClass: [CustomCell class]])
{
cell = (CustomCell *)currentObject;
}
}
}
//cell.txt1.text = @"0";
return cell;
}
Thanks all..
Cells are reusable, so they need a more persistent way to keep their info.
Method 1:
You could hold some
UITextFieldobjects into an array in case you don’t want to reuse the textfields as well, and atcellForRowAtIndexPathyou’d only need to set the textfields to their cells such as:Method 2:
If you want to reuse the textfields as well I suggest using an array with mutable dictionaries, each dictionary holding the ‘settings’ for a cell. The textfields will be fully managed by the custom cell (e.g: at the
UIControlEventValueChangedevent update @”txt1″ or @”txt2″ values from the dictionary attached to the cell).