I have to validate, questions on the basis of the odd or even week. If there is odd week then I will have to show different questions from even week. I am getting the questions from server from a "GET" method.
Asked
Active
Viewed 176 times
-1
-
Possible duplicate of [Get the Week Number in iOS SDK](http://stackoverflow.com/questions/17587697/get-the-week-number-in-ios-sdk) – ZeMoon Mar 03 '16 at 13:38
1 Answers
1
try this
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponent = [calendar components:(NSWeekOfYearCalendarUnit) fromDate:[NSDate date]];
NSLog(@"%lu",(long unsigned)dateComponent.weekOfYear);
bool isEven = (dateComponent.weekOfYear % 2) == 0

techloverr
- 2,597
- 1
- 16
- 28
-
`BOOL isEven = (dateComponent.weekOfYear & 1) == 0;`. Original code from this [answer](http://stackoverflow.com/a/17587863/299924). Note: your code will crash. – trojanfoe Mar 03 '16 at 13:38
-