伙计们,我在 XCODE4.5 中遇到了一些麻烦,希望您能帮助我!
如何使用方法 didSelectRowAtIndexPath 将 UITableViewController 中选定行的整数值传递或发送到另一个 ViewController?
这是我的代码:
SecondViewController.h
{
NSInteger myInteger;
}
@property(nonatomic) NSInteger myInteger;
SecondViewControl.m
-(void)viewDidLoad {
NSLog(@" the number is = %d",myInteger); //this is not working, I always get "the number is = 0 "
}
FirstViewController.h
#import "SecondViewController"
//...
FirstViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath) {
NSIndexPath *path = indexPath;
NSInteger theInteger = path.row;
NSLog(@"selected row = %d", theInteger); //code OK
//THE PROBLEM STARTS HERE!!!!!!!!!!!!!!!!!!
SecondViewController *second = [[SecondViewController alloc]init];
[second setMyInteger:theInteger];
// i'm trying to use "second.myInteger = theInteger;" , but it's also not working
}
}
谢谢你们!