One caution about using NSDateComponents, NSCalendar, etc… is that they are 
considerably slower than the CF date code. We took code written using the NS 
versions and rewrote them as CF version and the performance was easily 10x. Of 
course it was mostly noticeable only in loops where we were doing lots of 
iterations, but on the iPhone it was noticeable to the user even in short loops 
of 10 items or so. 

On Jan 4, 2010, at 11:59 AM, Wyatt Webb wrote:

> 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/alex%40webis.net
> 
> This email sent to a...@webis.net

Alex Kac - President and Founder
Web Information Solutions, Inc.

"The optimist proclaims that we live in the best of all possible worlds; and 
the pessimist fears this is true."
-- James Clabell




_______________________________________________

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

Reply via email to