我正在向模型中的 NSMutableArray 堆栈添加对象。这是界面:
@interface calcModel ()
@property (nonatomic, strong) NSMutableArray *operandStack;
@end
和实施:
@implementation calcModel
@synthesize operandStack = _operandStack;
- (NSMutableArray *)operandStack;
{
if (_operandStack == nil) _operandStack = [[NSMutableArray alloc]init];
return _operandStack;
}
这个 addobject 方法工作正常:
- (void)pushValue:(double)number;
{
[self.operandStack addObject:[NSNumber numberWithDouble:number]];
NSLog(@"Array: %@", self.operandStack);
}
但这一个使应用程序崩溃,并在日志中显示“lldb”:
- (void)pushOperator:(NSString *)operator;
{
[self.operandStack addObject:operator];
NSLog(@"Array: %@", self.operandStack);
}
是什么导致了这个错误?