How to get a specific day of the week in objective c?
Using the Gregorian calendar, I can get the number of the day of the week (e.g. 1 for Sunday and 2 for Monday, etc.), but I cannot find a function that displays the name of the week, then the number. Can anyone please help?
Here is my code to get the number of days:
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);
+2
a source to share