对不起这个问题。我必须节省点击按钮的时间
第一次,然后将时间与未来时间进行比较,如果大于或
等于我必须触发一个方法或一个警报的同时。
这是代码。
-(IBAction)checkInButtonClicked
{
now = [NSDate date];
[[NSUserDefaults standardUserDefaults]setObject:now forKey:@"theFutureDate"];
NSTimeInterval timeToAddInDays = 60 * 60 * 24;
theFutureDate = [now dateByAddingTimeInterval:timeToAddInDays];
switch ([now compare:theFutureDate]){
case NSOrderedAscending:{
NSLog(@"NSOrderedAscending");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:
[NSString stringWithFormat:@"Oops! The Check In will activate after 24Hrs"]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil ];
[alert show];
}
break;
case NSOrderedSame:{
NSLog(@"NSOrderedSame");
[self insertPoints];
}
break;
case NSOrderedDescending:{
NSLog(@"NSOrderedDescending");
}
break;
}
}
但是这段代码不能完全正常工作。谁能帮帮我。
提前致谢。