how to fetch value from TextField dynamically in iphone xcode
create IBOutlet UITextfield *MyTextfield;
in your class... connect it to the textfield that you have created in Interface builder (i guess you're using IB...)
you can then fetch value of Textfield by
MyTextfield.text
anywhere in your code
hi mihir
actually i wanna fetch the value dynamically through programatically without using IB...
Thanks
The class UITextField has a property named text, so you can do something like:
UITextField* textfield = // .. get access to object somehow NSString* text_of_textfield = [textfield text];
Objective-C adds some syntactic sugar on top of properties, though, so it is more concise to use:
UITextField* textfield = // .. get access to object somehow NSString* text_of_textfield = textfield.text; // same as [textfield text]
To manually instantiate a textfield without using interface builder (although, IMHO, that's the best way):
UITextField* field = [[UITextField alloc] init]; field.text = @"Initial value"; // can replace with whatever value you want
Note that you have to release or autorelease the textfield as is appropriate.
im using a table view in that when user enters data i want that value to store there are many cell like this on which event i should code is it i should code in textfield done editing
If you have created your textfield programmatically you have to keep a reference to the textview in order to access its value.
For example you use an instance variable of the viewController which keeps the reference to the textfield, which you set when you create your textfield.