2011-05-16 41 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

相關問題