On Jan 4, 2010, at 10:35 AM, Eric E. Dolecki wrote: > I am creating an iPhone view that has 12 months of views in it starting with > January. > > For each subview (month) I need to get the 1st day of the month (which > calendar day it falls on as an int). For instance Jan 2010 begins on a > Friday (int of 5 I assume). > > This way I can properly populate the UILabels I am positioning in each > subview. > > I saw this: http://theocacao.com/document.page/389 > > but I can't get it to work for the iPhone. I am going through docs and > google at the moment. Any help appreciated. > > Eric
I think the best approach would be a combination of NSDate, NSCalendar, and NSDateComponents. You could create an NSDate for the first of each month (1/1, 2/1, 3/1, etc.) and then use the components:fromDate: method on NSCalendar with the NSWeekdayCalendarUnit constant to get the day of the week for the first of the month. That comes out as an int from 1 to 7 (1 is Sunday, 7 is Saturday, so Friday would be 6). Wyatt_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com