我在使用 2 个对象初始化NSMutableArray
调用时遇到问题。我收到以下错误:_entryArray
NSString
@"00:00:00"
由于未捕获的异常“NSRangeException”而终止应用程序,原因:“ * -[__NSArrayM objectAtIndex:]: index 1 beyond bounds for empty array”
当我尝试在其中没有任何对象的情况下对其进行初始化时,我没有收到任何错误。我该怎么办?
非常感谢你
代码:
@implementation MainViewController{
@private
int n;
NSMutableArray *_entryArray;
NSMutableArray *_timeSinceLastEntryArray;
NSMutableArray *_timeInterval;
NSMutableArray *_timeInBackup;
NSMutableArray *_timeOutBackup;
BOOL whichButton;
}
-(void)viewWillAppear:(BOOL)animated {
}
- (void)viewDidLoad
{
[super viewDidLoad];
n=0;
_brain = [[Brain alloc] init];
_entryArray = [[NSMutableArray alloc] initWithObjects:@"00:00:00",@"00:00:00",nil];
_timeSinceLastEntryArray = [[NSMutableArray alloc] init];
_timeInBackup = [[NSMutableArray alloc] initWithObjects:(NSNumber *)0, nil];
_timeOutBackup = [[NSMutableArray alloc] initWithObjects:(NSNumber *)0, nil];
_timeInterval = [[NSMutableArray alloc] init];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
}