新手,正在研究可编程计算器。
在模型类的接口中CalculatorBrain
,我声明
@property (nonatomic, strong) NSMutableArray *whatHappenedSinceLastClear;
然后在实现中我也声明
-(NSMutableArray *)whatHappenedSinceLastClear
{
if(!_whatHappenedSinceLastClear) _whatHappenedSinceLastClear = [[NSMutableArray alloc] init];
return _whatHappenedSinceLastClear;
}
接着
-(double)runProgram:(id)whatHappenedSinceLastClear
{
NSMutableArray *mutableCopyOfWhatHappenedSinceLastClear;
if ([program isKindOfClass:[NSArray class]]) {
mutableCopyOfWhatHappenedSinceLastClear = [whatHappenedSinceLastClear mutableCopy];
}
return [self popOffProgramStack:mutableCopyOfWhatHappenedSinceLastClear];
}
但是在 ViewController 中,当我声明
-(IBAction)testPressed:(id)sender
{
CalculatorBrain *brain = self.brain;
brain = [[CalculatorBrain alloc] init];
NSMutableArray *program = brain.whatHappenedSinceLastClear;
[brain runProgram:program];
}
在该行中,NSMutableArray *program = brain.whatHappenedSinceLastClear;
我收到一条消息,上面写着“在'CalculatorBrain *'类型的对象上找不到属性'whatHappenedSinceLastClear'。
我究竟做错了什么?