ReceiverViewController.h
@property (nonatomic, assign) NSInteger currrentIndex;
ReceiverViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Index value %d",self.currrentIndex);
}
数据传递视图控制器.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
DataPassingViewController *detailViewController = [[DataPassingViewController alloc] initWithNibName:@"DataPassingViewController" bundle:nil];
detailViewController.currrentIndex = 5;
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}
我使用了上面的代码,其输出如下:
2013-07-10 17:50:10.230 DataPassing[3881:c07] Index value 5