1

I have two View Controllers: MainScreenViewController and TargetScreenViewController;

In MainScreenViewController I have UITableView with custom cells, in TargetScreenViewController I have the label which i need change.

I need to get some value, index path for example, and pass it along to TargetScreenViewController and change the label based on that value.

I already setup the push segue in Triggered Segues in cell, but how can i pass some value and get it there?

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    TargetView *target = [[TargetView alloc]initWithNibName:@"TargetView" bundle:nil];

    NSString *data = @"Success";

    target.incomingData = data;

}

in TargetView:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.mLabel.text = self.incomingData;
}

but label is blank =[

Oleg_Korchickiy
  • 298
  • 5
  • 15
  • take a look at http://stackoverflow.com/questions/7864371/ios5-how-to-pass-prepareforsegue-an-object – KIDdAe Nov 07 '13 at 09:39

3 Answers3

0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    Class *yourObject=[self.arr objectAtIndex:indexPath.row];

    TargetView *vc=[[TargetView alloc] initWithNibName:@"TargetView" bundle:nil];

    vc.object=yourObject; //Create a p

    [self.navigationController pushViewController:vc animated:YES];

}

In your TargetView

-(void)viewDidLoad{

   self.lbl.text=self.object.value;

}
iphonic
  • 12,615
  • 7
  • 60
  • 107
0

You can make a notification and post notification with a object. The object what you need to send to second Controller.

Voda Ion
  • 3,426
  • 2
  • 16
  • 18
0

try this .....

1.create a property in your target view controller .

2.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
      targetviewcontroller * obj = create object here .
      obj.property = dataToBeSent ;

      ---------------
}

then you will get your data by accessing property

Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70