我已经看到很多方法可以获得工作日,但没有一个方法来自选定的一天。
NSDate * selectedDate = _selectedDate //From Params
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *components = [cal components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:[[NSDate alloc] init]];
NSInteger weekday = [components weekday];
我应该如何以及在何处插入所选日期?
由于[components setDay:(INTEGER REQUIRED)] 它是一种将所选日期转换为当天的方法..任何人都有这个线索吗?
感谢的
答案 0 :(得分:0)
你试过吗?
NSDateComponents *components = [cal components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:selectedDate];
答案 1 :(得分:0)
NSDateComponents *components =
[cal components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
fromDate:selectedDate];