iOS 自动计算日期 - 一般人我不告诉他

- (NSMutableArray*)GetTomorrowDay:(int)day

{

NSDate*date = [NSDatedate];

NSMutableArray*arr = [NSMutableArrayarray];

NSCalendar*gregorian = [[NSCalendaralloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];

NSDateComponents*components = [gregoriancomponents:NSCalendarUnitWeekday|NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDayfromDate:date];

NSDateFormatter*formater = [[NSDateFormatteralloc]init];

[formatersetDateFormat:@"MM-dd"];

NSString*curTime = [formaterstringFromDate:date];

[arraddObject:curTime];

for(inti =1; i

{

[componentssetDay:([componentsday]+1)];

NSDate*beginningOfWeek = [gregoriandateFromComponents:components];

NSDateFormatter*dateday = [[NSDateFormatteralloc]init];

[datedaysetDateFormat:@"MM-dd"];

[arraddObject:[datedaystringFromDate:beginningOfWeek]];

}

returnarr;

}

输入数值 ,返回当天到数值的日期

你可能感兴趣的:(iOS 自动计算日期 - 一般人我不告诉他)