dontWatchMyProfile
dontWatchMyProfile

Reputation: 46310

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 could localize these myself but I bet that I can suck them out from a calendar class or something similar?

Upvotes: 1

Views: 473

Answers (3)

Johannes Fahrenkrug
Johannes Fahrenkrug

Reputation: 44730

This is what you want:

NSArray *weekdays = [[[NSDateFormatter alloc] init] weekdaySymbols];
NSLog(@"%@", weekdays);

Output:

(
    Sunday,
    Monday,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday
)

Enjoy!

Upvotes: 4

progrmr
progrmr

Reputation: 77191

Why don't you just use the monthSymbols array from NSDateFormatter?

Upvotes: 1

Ole Begemann
Ole Begemann

Reputation: 135550

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.

Upvotes: 1

Related Questions