NSDateComponents week deprecated with iOS8. Apple suggests using weekOfMonth or weekOfYear instead, depending on the context, but they work differently. For instance:
components1 = [calendar components:NSMonthCalendarUnit | NSWeekCalendarUnit | NSDayCalendarUnit fromDate:[self date7DaysAgo] toDate:[NSDate date] options:0];
components1 returns month = 0, week = 1, day = 0, weekOfMonth and weekOfYear are 2147483647 (integer maximum value).
components2 = [calendar components:NSMonthCalendarUnit | NSWeekCalendarUnit | NSDayCalendarUnit fromDate:[self date30DaysAgo] toDate:[NSDate date] options:0];
components2 returns month = 1 (I know it depends, but this is just an example), week = 0, day = 0, weekOfMonth and weekOfYear are 2147483647 (integer maximum value).
week returns the number of weeks over a period (if it was a week or more), and this is completely different from the number of weeks in a month or year. Why did Apple suggest using this instead?
source share