NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; //拿到当前时间 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; //当前时间 NSDate *nowDate = [NSDate date]; NSString *nowDateStr= [dateFormatter stringFromDate:nowDate]; //之前时间 NSString *agoDateStr = [userDefault objectForKey:@"saveNowDate"]; //判断时间差 if ([agoDateStr isEqualToString:nowDateStr]) { //是当天时间 }else{ //不是当天,需要提示 //这里写提示相关代码 //保存当前时间 [userDefault setObject:nowDateStr forKey:@"saveNowDate"]; [userDefault synchronize]; }