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

  • Home
  • SEARCH
  • 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 8465765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:08:35+00:00 2026-06-10T15:08:35+00:00

I have a table populated with a mutable array. The cells are custom, with

  • 0

I have a table populated with a mutable array. The cells are custom, with an UITextView, delegated on the customcellclass, which value I’d like to keep. It gets erased after every table reloadData.

Any idea about how to keep it? The ideas I had, and not able to go for:

  • Store the textView value on the same array which populates the table. From where? TextViewDidEndEditing? How to pass the value, and how to know which row was it?
  • Maintain an array of textViews apart from the other. Same problem of communicating cell-table and then I have to maintain this array also. Besides, I should take the textView away from the .nib.
    …I don’t came up with more know.

Any approach or help will be much appreciated. Thank you!

PS: I did lots of searches, most directing to forms, but this is a mutable array, I’ll have undefined rows on the table.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";


GuiCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


if (cell == nil) {
    NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"GuiCustomCell" owner:nil options:nil];

    for (UIView *view in views) {
        if([view isKindOfClass:[UITableViewCell class]])
        {
            cell = (GuiCustomCell*)view;
        }
    }   
}

if (timesArray || [timesArray count]) {        

    TakenTime *time = [[TakenTime alloc] init];
    time = [timesArray objectAtIndex:indexPath.row];

    if ([timeFormat isEqualToString:@"seconds"]) {
        cell.detailTextLabel.text = [time stringTimeFormat2];
    } else {
        cell.detailTextLabel.text = [time stringTimeFormat1];
    }

    cell.detailTextLabel.font = [UIFont systemFontOfSize:25];
    cell.textLabel.font = [UIFont systemFontOfSize:18];
    cell.textLabel.textAlignment = UITextAlignmentLeft;
    cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
    cell.textLabel.text = [NSString stringWithFormat:@"%i.",indexPath.row+1];        

}else{

    cell.textLabel.text = @" ";

}

[cell setDefaultText:TRUE];

return cell;

}

  • 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-06-10T15:08:37+00:00Added an answer on June 10, 2026 at 3:08 pm

    Set cell.textLabel.delegate to self (your UIViewController), then in the textFieldDidEndEditing: method, you can retrieve the indexPath corresponding to the cell in which the UITextField is located this way:

    -(void)textFieldDidEndEditing:(UITextField*)aTextField
    {
        UITableViewCell* containerCell = (UITableViewCell*)aTextField.superview;
        NSIndexPath* indexPath = [self.tableView indexPathForCell:containerCell];
        // Store the text, for example in an NSMutableDictionary using the indexPath as a key
        [self.mutableDictionaryOfTextValues setValue:aTextField.text forKey:indexPath];
    }
    

    Of course, in your tableView:cellForRowAtIndexPath: method, you will retrieve the text value stored in [self.mutableDictionaryOfTextValues objectAtIndex:indexPath] and affect it to cell.textLabel.text to restore the previously typed text.

    Don’t forget to instanciate your NSMutableDictionary (self.mutableDictionaryOfTextValues = [NSMutableDictionary dictionary];) in your init method of your UIViewController or some place similar.


    Note that this will only work if you end the edition of the UITextField before scrolling, that is when your UITextField receive resignFirstResponder (e.g. if you dismiss the keyboard, or the user click in another UITextField that will become the new firstResponder), because that’s when the textFieldDidEndEditing: delegate method is called.
    If you want to store the text each time the user type a character or modify the text, without waiting for the user to go on another textfield and textFieldDidEndEditing: is fired, you can use the textField:shouldChangeCharactersInRange:replacementString: delegate method instead:

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    {
        // Compute the new text that we will obtain once the new character has been validated
        NSString* newText = [textField.text replaceCharactersInRange:range withString:string];
        // Store it in our dictionary. Same as before, but use newText instead of textField.text
        UITableViewCell* containerCell = (UITableViewCell*)aTextField.superview;
        NSIndexPath* indexPath = [self.tableView indexPathForCell:containerCell];
        // Store the text, for example in an NSMutableDictionary using the indexPath as a key
        [self.mutableDictionaryOfTextValues setValue:newText forKey:indexPath];
        // Accept the new character
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which is being dynamically populated, each row contains two textfields
I have a table which is being dynamically populated from MySQL. The table has
I have a table populated via a DB and it renders like so (it
I have a populated table from a database in my VB ASP.NET application, like
I have a table which is populated by a daily scheduled job that deletes
I have a mutable Array in a Tableview, this is populated on View did
I have a table which is already populated. I need to change the data
I have a table populated with time stamped rows inserted at (essentially) random point
I have a table (in a form) populated with radio buttons (with a button
I have a large table that get populated from a view. This is done

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.