Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get NSArray of localised day-of-week names in IOS?

How to get NSArray of localised day-of-week names in IOS?

i.e. don't want to have to hardcode them in myself. Is there an easy way to get this from an IOS class? All I can think of is to write a method that steps through 7 days and then using the formatter output the Day of Week and collect these up

like image 975
Greg Avatar asked Nov 23 '11 00:11

Greg


1 Answers

It's as simple as this:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSLog(@"%@", [dateFormatter weekdaySymbols]); // or rather, whatever you
                                              // actually want to do with
                                              // the list
[dateFormatter release];

Or use shortWeekdaySymbols (for Mon, Tue, etc in English) or veryShortWeekdaySymbols (for M, T, etc) as you prefer.

like image 115
Tommy Avatar answered Nov 01 '22 10:11

Tommy