我正在将 date1 与 date2 与一小段代码进行比较,并收到崩溃通知。
我在 NSUserDefaults 中得到 date1:
NSDate *date1 = [[NSUserDefaults standardUserDefaults]
objectForKey:@"date1"];
NSDate *date2 = [[NSDate alloc] init];
if (fabs([date2 timeIntervalSinceDate:date1]) < 60)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"60 seconds or less" message:@"Text" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
return;
}
我将 date1 存储在 NSUserDefaults 中,如下所示:
NSDate *date1 = [[NSDate alloc] init];
[[NSUserDefaults standardUserDefaults] setObject:date1 forKey:@"date1"];
[[NSUserDefaults standardUserDefaults] synchronize];
该应用程序崩溃说 -[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance。有人有想法么?
谢谢!