Manipulating text field values ​​in an iPhone app

How to manipulate text variables in an iPhone app? I want to have three text boxes formatted for numbers only and be able to manipulate the data when different buttons are pressed.

Any help would be appreciated!

+1


source to share


3 answers


UITextField objects have a "text" property of type NSString that can be read and written. Keep the reference to the text boxes, and when the button is clicked, update the text property of the box with a new NSString to change its contents. If text fields cannot be directly editable by the user, you can use a UILabel instead, which is basically just an editable text field (and which also has a read / write "text" property).



+3


source


You can also read about a class NSNumberFormatter

that allows you to format the input in any way that suits your application (currency values, floats, etc.).



+1


source


To fix the issue of editing certain text fields, you can disable user interaction until the button is clicked.

0


source







All Articles