- [NSDateComponents week] is deprecated that enumeration gives the same behavior as before?

The documentation for NSDateComponents says that with iOS 7, week is deprecated and use weekOfDay or weekOfYear instead.

If I want to get the same logic as when I used it week, which one should I use?

I have used this in many places in my code, so analyzing each scenario is cumbersome. If there was one transfer, compared with the same as last week, this would save a lot of time.

+4
source share
1 answer

, :

    NSDateComponents *todayComps =
    [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit | NSWeekCalendarUnit
                fromDate:[NSDate date]];
Hide result

todayComps.week , 39.

, , todayComps.week todayComps.weekOfYear.

NSWeekOfYearCalendarUnit NSWeekCalendarUnit.

!

+10

All Articles