Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I remove objects created at runtime when a certain condition is met?
    primarykey
    data
    text
    <pre><code>- (IBAction)namePoints:(id)sender { yValuePoints = 180; pointTextBoxCounter = 0; while (numberOfPointsTextBox.text.intValue &gt; currentPointTextBox) { CGRect textFrame = CGRectMake(245, yValuePoints, 60, 30); UITextField *textField = [[UITextField alloc] initWithFrame:textFrame]; [textField setBackgroundColor:[UIColor whiteColor]]; [textField setBorderStyle:UITextBorderStyleRoundedRect]; textField.textAlignment = UITextAlignmentRight; [self.view addSubview:textField]; currentPointTextBox += 1; yValuePoints += 40; if (yValuePoints &gt; mainScrollView.contentSize.height) { [mainScrollView setContentSize:CGSizeMake(320, (yValuePoints + 20))]; } } while (numberOfPointsTextBox.text.intValue &lt; currentPointTextBox) { [self.view.subviews.lastObject removeFromSuperview]; //[[pointsTextFieldsArray objectAtIndex:currentPointTextBox] removeFromSuperview]; currentPointTextBox -= 1; } </code></pre> <p>}</p> <p>This function is called when numberOfPointsTextBox didFinishEditing. CurrentPointTextBox is an int that (hopefully) keeps track of the number of point text boxes currently on the screen (there others such as planes with a similar function). What I would like is when the value of numberOfPointsTextBox is decreased for the extra point text boxes to be removed. What I have been trying to do is use pointsTextFieldsArray to keep track of the index values of the fields that I have created in the self.view.subviews array so that I can just run the commented out line of code, but NSMutableArray's won't accept int values and I can't find a way find to dynamically create NSIntegers. Does anyone know how to do this? Or a better way to do it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload