My goals:
Determine current day of the week (Sun = 1, Mon = 2, etc.)
so that i can(if dayInt == 2){ ...
Then compare current time to set time forming a nested if with the statement above
(if curTime > 9:00am && curTime < 11:00am){...
I've researched this topic and found the below code is a somewhat popular way of doing the first objective. I found the below code at
iPhone - how may I check if a date is Monday?
However, for some reason it causes a breakpoint in my code. It tells me to replace NSWeekdayCalendarUnit
with NSCalendarUnitWeekday
(which I do) and have dayInt
be a long
(which I have tried), but these still do not work.
It builds but then causes a breakpoint. If dayInt
is an int
it says the value is 0, but if it is long
it comes out as 256. I don't really see a need for it to be long though. Any ideas?
NSDate* curDate = [NSDate date];
int dayInt = [[[NSCalendar currentCalendar] components: NSWeekdayCalendarUnit fromDate: curDate] weekday];