Note that there are some explanatory texts on larger screens.

plurals
  1. POGet values from several UITextFields
    primarykey
    data
    text
    <p>I have a grouped static UITableViewController, with 3 rows per section. Each row contains a UITextField. How do I get the value for each UITextField? </p> <p>So far, what I've seen is how to get the value of one UITextField. What should I do if I have to get more than one.</p> <p>I plan to put the values of these fields in a NSMutableDictionary.</p> <p>Here's my code for making the table view: (irrelevant parts are omitted)</p> <pre><code>#import "AddItemTableViewController.h" #import "iMonggoFetcher.h" @interface AddItemTableViewController() &lt;UITextFieldDelegate&gt; @property (weak, nonatomic) NSMutableDictionary *productItem; //required @property (weak, nonatomic) IBOutlet UITextField *stockNoTextField; @property (weak, nonatomic) IBOutlet UITextField *nameTextField; @property (weak, nonatomic) IBOutlet UITextField *retailPriceTextField; //basic info @property (weak, nonatomic) IBOutlet UITextField *costTextField; @property (weak, nonatomic) IBOutlet UITextField *descriptionTextField; @property (weak, nonatomic) IBOutlet UITextField *barcodesTextField; @property (weak, nonatomic) IBOutlet UITextField *tagsTextField; @property (weak, nonatomic) IBOutlet UISwitch *exemptFromTaxSwitch; //advanced features @property (weak, nonatomic) IBOutlet UISwitch *allowDecimalQuantitiesSwitch; @property (weak, nonatomic) IBOutlet UISwitch *enableOpenPriceSwitch; @property (weak, nonatomic) IBOutlet UISwitch *disableDiscountSwitch; @property (weak, nonatomic) IBOutlet UISwitch *disableInventorySwitch; @end @implementation AddItemTableViewController @synthesize productItem = _productItem; @synthesize stockNoTextField = _stockNoTextField; @synthesize nameTextField = _nameTextField; @synthesize retailPriceTextField = _retailPriceTextField; @synthesize costTextField = _costTextField; @synthesize descriptionTextField = _descriptionTextField; @synthesize barcodesTextField = _barcodesTextField; @synthesize tagsTextField = _tagsTextField; @synthesize exemptFromTaxSwitch = _exemptFromTaxSwitch; @synthesize allowDecimalQuantitiesSwitch = _allowDecimalQuantitiesSwitch; @synthesize enableOpenPriceSwitch = _enableOpenPriceSwitch; @synthesize disableDiscountSwitch = _disableDiscountSwitch; @synthesize disableInventorySwitch = _disableInventorySwitch; - (IBAction)save:(UIBarButtonItem *)sender { [self.productItem setValue:self.stockNoTextField.text forKey:IMONGGO_PRODUCT_STOCK_NO]; [self.productItem setValue:self.nameTextField.text forKey:IMONGGO_PRODUCT_NAME]; [self.productItem setValue:self.retailPriceTextField.text forKey:IMONGGO_PRODUCT_RETAIL_PRICE]; } #pragma mark - UITextField - (BOOL)textFieldShouldReturn:(UITextField *)textField { return YES; } - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { return YES; } - (void)textFieldDidEndEditing:(UITextField *)textField { // optionally trigger delegate method here } #pragma mark - View lifecycle - (void) viewWillAppear:(BOOL)animated{ //[self.stockNoTextField becomeFirstResponder]; } - (void) viewDidLoad{ [super viewDidLoad]; self.stockNoTextField.delegate = self; self.nameTextField.delegate = self; self.retailPriceTextField.delegate = self; //will do the rest later, just trying it out for now } @end </code></pre>
    singulars
    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.
 

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