You can use a DateFormatter to get the day of the week for a specific date as a string. You can also use NSDateComponents to get an integer value that represents the day of week.
See this SO post and answers...
문제
For example, given a date 13/09/2013(it is Saturday), how can I know what day it is in code? are there some methods in NSCalendar or NSdate can calculate this for me?
해결책
You can use a DateFormatter to get the day of the week for a specific date as a string. You can also use NSDateComponents to get an integer value that represents the day of week.
See this SO post and answers...
다른 팁
You can also (but I'm not sure if it's better in any way) get the weekday component and names from the calendar.
NSDate *yourDate = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *weekdayComponent =
[calendar components:NSWeekdayCalendarUnit
fromDate:yourDate];
NSString *dayName = calendar.weekdaySymbols[weekdayComponent.weekday-1];
NSLog(@"today is %@", dayName); // Output: today is Thursday