2011-05-16 38 views
0

我在建设和iOS应用程序,需要最小的日历。就在这个月的几天。有没有人遇到过裸机源代码 - c-code是好的 - 当给定一个月和一年可以产生正确的月份?有人可以将我指向每月的几天源代码吗?

感谢,
道格

+0

你需要一周的几天? – jason 2011-05-16 15:15:31

+0

另外,我没有做iOS,但如果没有内置于iOS的功能为您做到这一点,我会感到震惊。 – jason 2011-05-16 15:16:16

+0

这是'c'还是'objective-c'。如果是后者,那么这应该被重新标记。 – BMitch 2011-05-16 15:43:32

回答

3

看一看IOS的日期和时间编程指南http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/DatesAndTimes/Articles/dtCalendars.html#//apple_ref/doc/uid/TP40003470-SW1

他们有下面的例子演示如何获得星期几,从NSDate:

NSDate *today = [NSDate date]; 
NSCalendar *gregorian = [[NSCalendar alloc] 
        initWithCalendarIdentifier:NSGregorianCalendar]; 
NSDateComponents *weekdayComponents = 
       [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:today]; 
NSInteger day = [weekdayComponents day]; 
NSInteger weekday = [weekdayComponents weekday]; 
+0

哇。我必须检查一下。凉。谢谢jjwchoy。 – dugla 2011-05-16 16:26:11

相关问题