开发者

how to get a particular day of week in objective c?

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 co开发者_JAVA技巧de 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);


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜