是否可以在iOS应用程序中获取当前和未来三天的月份详细信息。
答案 0 :(得分:0)
NSDateComponents *dayComponent = [[NSDateComponents alloc] init];
dayComponent.day = 1; // Here add your days
NSCalendar *theCalendar = [NSCalendar currentCalendar];
NSDate *nextDate = [theCalendar dateByAddingComponents:dayComponent toDate:[NSDate date] options:0];
NSLog(@"nextDate: %@ ...", nextDate);
月信息:
unsigned units = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:units fromDate: nextDate];
// get your month
NSInteger month = [components month];