I made a Text Field with interface builder. How can I get its text to use somewhere else?
Is there something like:
string text = myTextField.Text;
If so, how can I name my text field?
So the first thing you want to do is create a property in the .h file of the view controller files associated with your xib file like so:
@property (strong, nonatomic) IBOutlet UILabel *aLabel;
Next in the .m file you need to synthesize it like so:
@synthesize aLabel;
Within you implementation tag.
Now in interface builder control click where it says "File's Owner" on the left side of the screen in Xcode 4.3 hold down and drag over the label and let go. Then in the popup select the name of the property you created. Now in the viewDidLoad method of your view controller you can get at your value like so:
self.alabel.text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With