我正在努力继承 UIViewControllers 但遇到了问题。下面是我使用的 ViewController 列表及其流程。
头文件
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
子类中的日志打印 null 但根据我的理解,它们应该打印与 ParentView 中相同的值。如果我在某些地方错了,请指导我。
ParentView.listTickets: (
"<CustomerTicket: 0x4c75d90>",
"<CustomerTicket: 0x4c76310>"
)
listTickets: (null)
super.listTickets: (null)
self->listTickets: (null)
self.listTickets: (null)