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 6854261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:36:41+00:00 2026-05-27T01:36:41+00:00

This is an extension of this question here: UITextField randomly reusing text in tableview

  • 0

This is an extension of this question here: UITextField randomly reusing text in tableview

I’m having some issues with my table that has UITextFields in each cell. I notice text is still getting reused randomly in the wrong cells even though I seem to be saving it correctly.

 else if (tableView == self.vitalsTableView)
    {
        if ([indexPath row] == 2) {
            CellIdentifier = @"bloodPressureCell";
            BloodPressureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            cell.textField1.text = [self.vitalsDictionary objectForKey:@"blood_pressure_1"];
            cell.textField2.text = [self.vitalsDictionary objectForKey:@"blood_pressure_2"];
            self.bloodPressureTextField1 = cell.textField1;
            self.bloodPressureTextField2 = cell.textField2;
            return cell;
        }
        else if ([indexPath row] == 9){
            CellIdentifier = @"statusCell";
            SmokingStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            return cell;
        }
        else if ([indexPath row] == 10){
            CellIdentifier = @"vitalsCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            return cell;
        }
        else{
            CellIdentifier = @"textCell";
            VitalsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            switch (indexPath.row) {
                case 0:
                    cell.vitalsLabel.text = @"Temperature";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"temperature"];
                    self.temperatureTextField = cell.textField;
                    break;
                case 1:
                    cell.vitalsLabel.text = @"Pulse";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"pulse"];
                    self.pulseTextField = cell.textField;
                    break;
                case 3:
                    cell.vitalsLabel.text = @"Respiratory Rate";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"respiratory_rate"];
                    self.respiratoryRateTextField = cell.textField;
                    break;
                case 4:
                    cell.vitalsLabel.text = @"Oxygen Saturation";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"oxygen_saturation"];
                    self.oxygenSaturationTextField = cell.textField;;
                    break;
                case 5:
                    cell.vitalsLabel.text = @"Height";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"height"];
                    self.heightTextField = cell.textField;
                    break;
                case 6:
                    cell.vitalsLabel.text = @"Weight";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"weight"];
                    self.weightTextField = cell.textField;
                    break;
                case 7:
                    cell.vitalsLabel.text = @"BMI";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"bmi"];
                    self.bmiTextField = cell.textField;
                    break;
                case 8:
                    cell.vitalsLabel.text = @"Pain (1-10)";
                    cell.textField.text = [self.vitalsDictionary objectForKey:@"pain"];
                    self.painTextField = cell.textField;
                    break;
                default:
                    break;
            }
            return cell;
        }

- (void) textFieldDidEndEditing:(UITextField *)textField{
    if (textField == temperatureTextField){
        [self.vitalsDictionary setObject:self.temperatureTextField.text forKey:@"temperature"];
    }
    else if (textField == pulseTextField){
        [self.vitalsDictionary setObject:self.pulseTextField.text forKey:@"pulse"];
    }
    else if (textField == respiratoryRateTextField){
        [self.vitalsDictionary setObject:self.respiratoryRateTextField.text forKey:@"respiratory_rate"];
    }
    else if (textField == oxygenSaturationTextField){
        [self.vitalsDictionary setObject:self.oxygenSaturationTextField.text forKey:@"oxygen_saturation"];
    }
    else if (textField == heightTextField){
        [self.vitalsDictionary setObject:self.heightTextField.text forKey:@"height"];
    }
    else if (textField == weightTextField){
        [self.vitalsDictionary setObject:self.weightTextField.text forKey:@"weight"];
    }
    else if (textField == bmiTextField){
        [self.vitalsDictionary setObject:self.bmiTextField.text forKey:@"bmi"];
    }
    else if (textField == painTextField){
        [self.vitalsDictionary setObject:self.painTextField.text forKey:@"pain"];
    }
    else if (textField == bloodPressureTextField1){
        [self.vitalsDictionary setObject:self.bloodPressureTextField1.text forKey:@"blood_pressure_1"];
    }
    else if (textField == bloodPressureTextField2){
        [self.vitalsDictionary setObject:self.bloodPressureTextField2.text forKey:@"blood_pressure_2"];
    }
}
  • 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-27T01:36:42+00:00Added an answer on May 27, 2026 at 1:36 am

    You cannot check by doing textField == pulseTextField, because UITableview will reuse cells in a unpredictable manner as long as the reuse identifiers match. You are storing a reference to a text field, but when you scroll up and down, that cell may get assigned a different index. So, you may end up with duplicate reference to the same text field, since some cells may be off-screen with outdated duplicate reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question already has an answer here: What are Extension Methods? 5 answers Usage
(Note: This is an extension of a previous question .) I am having some
As an extension to this question here Linking JavaScript Libraries in User Controls I
This is an extension of a question I previously asked here . Long story
This is an extension to a question which I asked some time ago. I
Hello every one this is extension to my previous question.Here is the link File
Note: This is an extension of an earlier question I asked here: Do additional
Note: This is an extension of an earlier question I asked here: Do additional
Based on some other code I found from this site (This Question here -
I have asked this question earlier, please click here ! this is extension to

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.