iOS--如何计算出今天是周几

iOS–如何计算出今天是周几?? 很简单:

1
2
3
4
5
6
7
8
9
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierRepublicOfChina];
NSInteger comp = [cal component:NSCalendarUnitWeekday fromDate:[NSDate date]];
NSLog(@"%ld",comp);
NSDateComponents *comps = [cal components:NSCalendarUnitWeekday fromDate:[NSDate date]];
NSLog(@"%@",comps);