2012-08-10 20 views
0

在one.m为什么该值不会传递到下一个TabbarViewController?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSUInteger row = [indexPath row]; 
    NSString *carNumber = [self.carNumberArrayFromPlistFile objectAtIndex:row]; 
    NSString *engineNumber = [self.engineNumberArrayFromPlistFile objectAtIndex:row]; 
    CarInfo *oneCarInfo = [[CarInfo alloc] initWithCarNumber:carNumber engineNumber:engineNumber]; 
    Two *two = [[Two alloc] initWithNibName:@"Two" bundle:nil]; 
    two.car = oneCarInfo; 
    [self.navigationController pushViewController:two animated:YES]; 
    [oneCarInfo release]; 
    [two release]; 
} 

在two.h

@interface Two : UITabBarController 
{ 
    CarInfo *car; 
} 
@property (nonatomic, retain)CarInfo *car; 

为什么在Two.m车上总是空?请帮我解决一下这个。感谢你们!

Two.m:

@interface Two() 
@end 

@implementation Two 
@synthesize car; 


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
    // Custom initialization 
    } 
    return self; 
} 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    self.car = nil; 
} 

- (void)dealloc 
{ 
    [super dealloc]; 
} 
@end 
+0

您是否认为汽车?你为什么从UITabBarController继承?你是用'car'还是'self.car'来引用汽车? – 2012-08-10 11:52:41

+0

谢谢你的回复,我很确定我认为汽车和汽车不是self.car – jxdwinter 2012-08-10 12:03:41

+0

你可以发布@synthesize的代码吗?出于好奇,如果你使用'self.car'而不是'car',会发生什么? – 2012-08-10 12:08:39

回答

0

@PeterPajchl:你不应该推的UITabBarController实例上的UINavigationController的堆栈 - 查看文档。

相关问题