How do I manipulate textfield variables within an iPhone app? I want to have three text fields, formatted to numbers only, and be able to manipulate the data when I press different buttons.
Any help would be appreciated!
How do I manipulate textfield variables within an iPhone app? I want to have three text fields, formatted to numbers only, and be able to manipulate the data when I press different buttons.
Any help would be appreciated!
UITextField objects have a "text" property of type NSString that can be read and written. Keep a reference to the text fields, and when a button is pressed, update the field's text property with a new NSString to change its contents. If the text fields are not directly editable by the user, you may want to use UILabel instead, which is basically just a non-editable text field (and which also has a read/write "text" property).
You may also want to read about the NSNumberFormatter
class that allows you to format the input into whatever way is relevant to your application (currency values, floats, etc).
To solve the problem of editing certain text fields, you could disable the user interaction until a button is pressed.