Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of unresolved identifier NSCalendarUnitDay

I just updated Xcode to its 6.3 version.

Except all the fixes I have to make regarding as (mainly), I have some warnings that just appeared (which is weird as it states it is since iOS 8.0).

My code

NSCalendar.currentCalendar().compareDate(self, toDate: date, toUnitGranularity: .DayCalendarUnit) == .OrderedAscending

is now shows a warning

'DayCalendarUnit' was deprecated in iOS version 8.0: Use NSCalendarUnitDay instead

Fine, then I'll change .DayCalendarUnit by NSCalendarUnitDay

Now I get an error saying:

Use of unresolved identifier 'NSCalendarUnitDay'

I'm confuse, can someone explain me what's wrong and how to fix it?

like image 367
Nico Avatar asked Apr 09 '15 04:04

Nico


2 Answers

Use .CalendarUnitDay. NSCalendar is a native Objective-C framework and the error messages aren't for swift.

like image 116
Schemetrical Avatar answered Oct 15 '22 18:10

Schemetrical


I think Apple thought the name of those units weren't meaningful like .DayCalendarUnit, so they have modified it to sound more sensible and explanative as .CalendarUnitDay.

Similar modifications have been done in Objective-C. NSDayCalendarUnit is deprecated and you have to use NSCalendarUnitDay.

The problem in your case is that you are receiving deprecation warning of Objective-C instead of Swift. We hope Apple fixes it soon.

Hope that explains...

like image 24
Mayur Deshmukh Avatar answered Oct 15 '22 17:10

Mayur Deshmukh