Reputation: 77631
I heard about a function on NSCalendar
that had been introduced in iOS7.
Had a look in the docs and couldn't find it. Nor in the OS X docs.
The function is - (BOOL)isDate:(NSDate *)date1 equalToDate:(NSDate *)date2 toUnitGranularity:(NSCalendarUnit)unit
i.e. are these two dates on the same day/in the same week/ month, etc...
However, when I try to use it in Xcode 5. The AutoComplete shows it with a red strike through and then when I actually use it I get this error...
It's odd as the function is clearly there I'm just not able to use it.
Can anyone shed light on why this is happening?
Upvotes: 2
Views: 638
Reputation: 56625
Unfortunately it's not available for iOS, only for OS X 10.9. You can always dupe rdar://14995171 to tell Apple that you want it for iOS as well.
If you look in NSCalendar.h in the iOS 7 SDK you will see that these methods are tagged as available since __NSCALENDAR_COND_IOS_7_0
which if you look at the top of the same file is defined as
#if !defined(__NSCALENDAR_COND_IOS_4_0)
#if NS_ENABLE_CALENDAR_NEW_API
#define __NSCALENDAR_COND_IOS_4_0 4_0
#define __NSCALENDAR_COND_IOS_5_0 5_0
#define __NSCALENDAR_COND_IOS_6_0 6_0
#define __NSCALENDAR_COND_IOS_7_0 7_0
#else
#define __NSCALENDAR_COND_IOS_4_0 NA
#define __NSCALENDAR_COND_IOS_5_0 NA
#define __NSCALENDAR_COND_IOS_6_0 NA
#define __NSCALENDAR_COND_IOS_7_0 NA
#endif
#endif
This currently evaluates to NA
meaning that these methods are "not available" for iOS.
Upvotes: 10
Reputation: 8337
Where did you hear about that method? It's possible that the method has been removed during the betas of iOS 7.
It's private API: __NSCFCalendar.h
Upvotes: 6