@interface MyViewController() {
NSDate *myCurrentDate;
}
@implementation MyViewController
-(void)viewDidLoad {
[super viewDidLoad];
myCurrentDate = [NSDate date];
}
- (IBAction) prevAction:(id)sender {
NSLog(@"myCurrentDate===%@", myCurrentDate); // here it says
myCurrentDate = [myCurrentDate dateByAddingTimeInterval:60*60*24*-1];
[self formatDateAndPostOnButton];
}
当我尝试如下打印当前的日期,它崩溃说BAD_EXCESS
NSLog(@"myCurrentDate===%@", myCurrentDate);
下面是相同的屏幕截图。
我不会在我的项目中使用ARC。
任何想法是什么问题?
这些是对mCurrentDate的唯一引用吗?或者你还在哪里使用它。在这些代码行中,我没有看到任何缺陷。 –
您是否通过逐步调试的方式进行了重复检查,确定该异常真的在这条线上。 –
@HermannKlecker:我有上一个和下一个按钮...我更新变量myCurrentDate然后我更新显示的标签... –