开发者

How to obtain a localized string representation of the weekdays like monday, tuesday, etc.?

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜