Reputation: 3842
i have a UIViewController with a text Field and a button . When the user click the button , i want to move to a TableViewCotroller and send the value of the text field to the table view . I use this code :
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:@"StatusTableViewController" bundle:nil];
[self.navigationController pushViewController:statuttableview animated:YES];
It work but i dont know how i will access to the text field value from StatusTableViewController . Help please
Upvotes: 0
Views: 1018
Reputation: 10775
You should definitely go a little deeper into the basics....
You have to add a NSString
property to the StatusTableViewController
and set it in a custom init or with its setter after initialization.
in StatusTableViewController.h
do something like
NSString *myText;
...
@property(nonatomic, retain) NSString *myText;
....
and/or
-(id)initWithNibName:(NSString *)nibname bundle:(NSBundle *)bundle text:(NSString *)text;
in StatusTableViewController.m do
@synthsize myText;
and/or
-(id)initWithNibName:(NSString *)nibname bundle:(NSBundle *)bundle text:(NSString *)text
{
if(self = [super initWithNibName:nibname bundle:bundle])
{
self.myText = text;
}
}
and in you code call the custom init or
statuttableview.myText = text
.
Upvotes: 1
Reputation: 1631
Create one NSString *str (variable) in StatusTableViewController.h file and do property,synthesize it.
After that do following code in your current controller,
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:@"StatusTableViewController" bundle:nil];
statuttableview.str=textfield.text;
[statuttableview.str retain];
[self.navigationController pushViewController:statuttableview animated:YES];
Upvotes: 0
Reputation: 826
get the value from textfield and and send that to string placed with property and syntesize in StatusTableViewController controller and use like this
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:@"StatusTableViewController" bundle:nil];
statuttableview.textValue=valueLocal;
[self.navigationController pushViewController:statuttableview animated:YES];
Upvotes: 0