Example usage [NSCalendar autoupdatingCurrentCalendar]

I am looking for an example where + autoupdatingCurrentCalendar will be used instead of + currentCalendar . More specifically, when the values ​​based on the calendar automatically change when the calendar changes. Do I need bindings for this or something like that?

Status of documents:

Please note that if the cache-based cache values ​​or related information is of course not updated automatically by updating the calendar object.

Thanks in advance

+8
objective-c cocoa nscalendar
source share
3 answers

currentCalendar returns the cached version of the current system calendar, and autoupdatingCurrentCalendar always returns the latest version of the system calendar.

This is important when you present data based on various calendar options, such as the number of days in a month, the number of weeks in a year, or the number of hours per day.

Honestly, I don’t know why Apple gives you the option to get an obsolete value using currentCalendar . It looks like they have an internal API that allows you to manipulate NSCalendar caches, so you can achieve better performance. But since it is not publicly available, there is no reason to use currentCalendar .

That is, always use autoupdatingCurrentCalendar .

+4
source share

Well, in OS X you can run multiple processes at the same time. Maybe your process uses autoupdatingCurrentCalendar . Others may be system settings.

System settings let you customize your calendar settings. You can select the first day of the week to be something other than the default (Sunday). Or you can choose a completely different calendar. If you use autoupdatingCurrentCalendar , these changes will be automatically raised. If you do not use it, they will not.

+1
source share

I assume this is only useful if you save the calendar in memory for future reference. If you change the calendar settings, your saved calendar will take these changes into account if you use autoupdatingCurrentCalendar. If you only used currentCalendar, it will remain in the state that was on the first call.

0
source share

All Articles