How to obtain a localized string representation of the weekdays like monday, tuesday, etc.?
Sure I c开发者_如何学编程ould localize these myself but I bet that I can suck them out from a calendar class or something similar?
This is what you want:
NSArray *weekdays = [[[NSDateFormatter alloc] init] weekdaySymbols];
NSLog(@"%@", weekdays);
Output:
(
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
)
Enjoy!
Given a valid NSDate
, NSDateFormatter
can output the name of the weekday with the date format @"EEEE"
. I don't know of a simpler way to do this in Cocoa.
Why don't you just use the monthSymbols array from NSDateFormatter?
精彩评论