i.e.:
NSDate *firstDayOfWeek = [[NSDate date] firstDayOfWeek];
for example, today is Aug 19, I’d want to get a NSDate of 2010-08-15 12:00am from above line of code. Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think this threads responds to what you’re looking for: http://www.cocoabuilder.com/archive/cocoa/211648-nsdatecomponents-question.html#211826
Note however that it doesn’t handle Mondays as first days of the week, so you may have to tweek it a little by substracting
[gregorian firstWeekday]instead of just1. Also, I modified it to use-currentCalendar, but it’s up to you 🙂