在setProgramandsetGraphic方法中,我们有相同的代码:
NSLog(@"%@", self.display);
但输出显示 self.display 在 中为空,但在setProgram中是UILable 对象setGraphic。
是什么导致了不同的结果?display是 IBOutlet 并且program是 NSArray 对象。虽然program是 SOGraphicViewController 的模型,但我将通过另一个控制器传递 program 的值[segue.destinationViewController setProgram: self.brain.program]。
@interface SOGraphicViewController ()
@property (nonatomic, weak) IBOutlet graphicView *graphic;
@end
@implementation SOGraphicViewController
@synthesize program = _program;
@synthesize graphic = _graphic;
@synthesize display = _display;
- (void)setProgram:(id)program {
_program = program;
[self.graphic setNeedsDisplay];
NSLog(@"%@", self.display);
}
- (void)setGraphic:(graphicView *)graphic {
_graphic = graphic;
self.graphic.dataSource = self;
NSLog(@"%@", self.display);
}