【发布时间】:2023-04-03 13:26:01
【问题描述】:
试图形成一个 if 语句,将左侧的当前日期与右侧的 UIDatePicker 中选择的日期进行比较,我认为这是我由 Stack Overflow 用户给出的正确代码,他们不应该能够执行此操作,他们不能,但我需要创建一个弹出窗口,告诉他们为什么不这样做:
//Get the current date
NSDate *pickerDate = [self.datePicker date];
//Unable to set notification for same day
//[datePicker setMinimumDate:[NSDate date]];
self.datePicker.date = [NSDate date];
if ([pickerDate compare:datePicker] == NSOrderedAscending) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something wasn't right." message:@"That did not work and your alarm was not set." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
我在执行此操作时收到以下错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIDatePicker timeIntervalSinceReferenceDate]:无法识别的选择器发送到实例 0x10b9373a0”
【问题讨论】:
标签: ios objective-c uilocalnotification