views:

204

answers:

1

Using the Gregorian calendar, I am able to get the number of the day of the week (i.e. 1 for Sunday and 2 for Monday, etc.) but I am not able to find a function that displays the name of week then the number. Can anyone help?

Here is my code to get the number of day:

NSDate *dates = [gregorian dateFromComponents:component];

NSDateComponents *weekdayComponents =[gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:dates];

NSUInteger *weekdays = [weekdayComponents weekday]; 


NSString *dayw=[NSString stringWithFormat:@"%1i",weekdays];

NSLog(@"%@",dayw);
+4  A: 

Create an NSDateFormatter. The format string @"EEEE" will output the name of the day of the week.

Ole Begemann
Additionally, if you use `EEE` you'll get the short name, and `EEEEE` will get you the "narrow" name (e.g. "T").
jtbandes
This too is what I use.
Jus' Wondrin'