面试准备第九篇
2019-12-24 本文已影响0人
凤毛麟角0712
```日历
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierChinese];// 农历
NSDate *currentDate = [NSDate date];
NSInteger weekIndexOfYear = [calendar ordinalityOfUnit:NSCalendarUnitWeekday
inUnit:NSCalendarUnitYear
forDate:currentDate];
NSLog(@"今天是今年的第%ld周",weekIndexOfYear);
NSInteger dayIndexOfMonth = [calendar ordinalityOfUnit:NSCalendarUnitDay
inUnit:NSCalendarUnitMonth
forDate:currentDate];
NSLog(@"今天是本月的第: %ld 天",dayIndexOfMonth);
```