Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6548711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:00:12+00:00 2026-05-25T12:00:12+00:00

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

  • 0

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

enter image description here

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

enter image description here

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..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:00:12+00:00Added an answer on May 25, 2026 at 12:00 pm

    Cells are reusable, so they need a more persistent way to keep their info.

    Method 1:
    You could hold some UITextField objects into an array in case you don’t want to reuse the textfields as well, and at cellForRowAtIndexPath you’d only need to set the textfields to their cells such as:

    cell.txt1 = [textFieldsArray objectAtindex:indexPath.section*2];
    cell.txt2 = [textFieldsArray objectAtindex:indexPath.section*2+1]; //txt1 and txt2 properties should have assign
    

    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 UIControlEventValueChanged event update @”txt1″ or @”txt2″ values from the dictionary attached to the cell).

    ///somewhere in the initialization (in the class holding the tableview)
    contentArray = [[NSMutableArray alloc] init];
    
    ///when adding a new cell (e.g: inside the 'Add set' action)
    [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"", @"txt1", @"", @"txt2", nil]];
    //add a new cell to the table (the same way you do now when tapping 'Add set')
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        ...
         [cell attachDictionary:[contentArray objectAtIndex:indexPath.section]];
        return cell;
    }
    
    ///anywhere where you'd like to access the values inserted inside a cell
    NSMutableDictionary *cell3Content = [contentArray objectAtIndex:3];
    NSString *text1 = [cell3Content valueForKey:@"txt1"];
    NSString *text2 = [cell3Content valueForKey:@"txt2"];
    
    ///CustomCell.m
    -(id)initWithCoder:(NSCoder *)decoder{
        self = [super initWithCoder:decoder];
        if(!self) return nil;
        [txt1 addTarget:self action:@selector(txt1Changed:) forControlEvents:UIControlEventValueChanged];
        [txt2 addTarget:self action:@selector(txt2Changed:) forControlEvents:UIControlEventValueChanged];
        return self;
    }
    -(void)attachDictionary:(NSMutableDictionary *)dic{
        contentDictionary = dic;
        txt1.text = [contentDictionary valueForKey:@"txt1"];
        txt2.text = [contentDictionary valueForKey:@"txt2"];
    }
    -(void)txt1Changed:(UITextField *)sender{
        [contentDictionary setValue:txt1.text forKey:@"txt1"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tableView with the custom cell (see image below.) Taking a three
I have a custom view in a custom table cell. Every time a specific
I have custom table view cell with images (loaded from app document directory), labels,
I have a custom Table View Cell that displays the details of a Conference
I have a custom cell that contains a button in a table view. The
i've problems with the scroll of my Table View. I have a custom cell
I have used custom cell in my tableview for different values and to save
I have few custom controls (image views) added programmatically to table cell. I want
I have a custom cell and i displayed that custom cell in a table
I have several parts in my app where I use custom table view cells.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.