i need to pass data between to Views. I really can't figure out why is not working. Variable selectedRow in SecondViewController is always empty.
FirstViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
SecondViewController *newView = [[SecondViewController alloc] init];
newView.selectedRow = [tablelist objectAtIndex:indexPath.row];
newView.title = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController:newView animated:YES];
}
SecondViewController.h
@interface SecondViewController : UIViewController
{
NSString *title,*selectedRow;
}
@property(nonatomic,retain) NSString *title;
@property (nonatomic,retain) NSString *selectedRow;
@end
SecondViewController.m
@synthesize title,selectedRow;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 64, 320, 370)];
textView.text = selectedRow;
textView.editable = FALSE;
[self.view addSubview:textView.text];
}
return self; }
I'm struggling for hours. I really cant figure why. Any help? Thank you