记录时间的日期,再进行日期的对比,相同则为同一天,不同则不是同一天
上代码
-(void)judgeUpDateVersion{
BOOL sameDateFlag = NO;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString *nowday = [formatter stringFromDate:[NSDate date]];
NSString *saveDay = [kUserDefaults objectForKey:@"versionUpdateKey"];
if (saveDay == nil) {
saveDay = @"";
}
if (![saveDay isEqualToString:nowday]) { //假如不是同一天,更新存储的日期,并且把flag置为YES
[kUserDefaults setObject:nowday forKey:@"versionUpdateKey"];
sameDateFlag = YES;
}
if (sameDateFlag) {
[self newVersionUpdateProcedure];
}
}
网友评论