我工作在继承UIViewControllers但我与它面临的问题。下面是我使用的ViewController列表及其流程。继承在UIViewController中
头文件
MainViewController : UIViewController {
}
CustomerTicketViewController : UIViewController {
}
@property (nonatomic, retain) NSArray *listTickets;
CustomerEditTicketViewController : CustomerTicketViewController {
}
实施文件
@implementation MainViewController
- (void)loadCustomer {
CustomerTicketViewController *customerTicketViewController = [[CustomerTicketViewController alloc] initWithNibName:@"CustomerTicketViewController" bundle:nil];
[customerTicketViewController setListTickets:myTickets];
[self presentModalViewController:customerTicketViewController animated:YES];
[customerTicketViewController release];
}
@end
@implementation CustomerTicketViewController
- (void)editCustomer {
CustomerEditTicketViewController *customerEditTicketViewController = [[CustomerEditTicketViewController alloc] initWithNibName:@"CustomerEditTicketViewController" bundle:nil];
NSLog(@"ParentView.listTickets: %@", listTickets);
[self presentModalViewController:customerEditTicketViewController animated:NO];
[customerEditTicketViewController release];
}
@end
@implementation CustomerEditTicketViewController
- (void)viewDidLoad {
NSLog(@"listTickets: %@", listTickets);
NSLog(@"super.listTickets: %@", super.listTickets);
NSLog(@"self->listTickets: %@", self->listTickets);
NSLog(@"self.listTickets: %@", self.listTickets);
}
@end
在子类打印空,但按我的理解,他们应该打印相同的值作为ParentView日志。 请指导我,如果我错了一些地方。
ParentView.listTickets: (
"<CustomerTicket: 0x4c75d90>",
"<CustomerTicket: 0x4c76310>"
)
listTickets: (null)
super.listTickets: (null)
self->listTickets: (null)
self.listTickets: (null)