![](/img/trans.png)
[英]Ho to get month/weekday symbols from NSDateFormatter in current language (iPhone)
[英]Get the weekday from a selected day and not from the current day
我見過很多方法來獲得工作日,但沒有一個是來自選定的一天。
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)] 是一種將所選日期轉換為當前日期的方法..有人對此有所了解嗎?
謝謝
你有沒有嘗試過?
NSDateComponents *components = [cal components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:selectedDate];
NSDateComponents *components =
[cal components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
fromDate:selectedDate];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.