//一天之内弹窗一次
NSUserDefaults*userDefault=[NSUserDefaults standardUserDefaults];
// NSLog(@"之前时间:%@", [userDefault objectForKey:@"nowDate"]);//之前存储的时间
// NSLog(@"现在时间%@",[NSDate date]);
//现在的时间NSDate*now=[NSDate date];
NSDate*agoDate=[userDefault objectForKey:@"nowDate"];
NSDateFormatter*dateFormatter=[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString*ageDateString=[dateFormatter stringFromDate:agoDate];
NSString*nowDateString=[dateFormatter stringFromDate:now];
if([ageDateString isEqualToString:nowDateString]){
NSLog(@"一天就显示一次");
}else{
}
网友评论