I am comparing date1 to date2 with a small bit of code, and am getting a crash notification.
I get date1 in NSUserDefaults with this:
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;
}
I am storing date1 in NSUserDefaults like this:
NSDate *date1 = [[NSDate alloc] init];
[[NSUserDefaults standardUserDefaults] setObject:date1 forKey:@"date1"];
[[NSUserDefaults standardUserDefaults] synchronize];
The app is crashing saying that -[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance. Anyone have any ideas?
Thank you!
I have compiled your code and it works for me. This is how it looks:
See if this compiles for you