Using an Unresolved NSCalendarUnitDay Identifier

I just updated Xcode to version 6.3.

With the exception of all the corrections I have to make regarding as (mainly), I have some warnings that have just appeared (which is strange, as it indicates that it is with iOS 8.0).

My code

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

now shows a warning

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

Ok, then I will change .DayCalendarUnit to NSCalendarUnitDay

Now I get the error message:

 Use of unresolved identifier 'NSCalendarUnitDay' 

I am embarrassed, can someone explain to me what happened and how to fix it?

+5
ios swift
source share
3 answers

Use .CalendarUnitDay . NSCalendar is the native Objective-C framework, and error messages are not for fast.

+10
source share

I think Apple thought that the name of these units does not make sense like .DayCalendarUnit, so they changed it to make it sound more sensible and explanatory as .CalendarUnitDay.

Similar changes were made in Objective-C. NSDayCalendarUnit is deprecated and you should use NSCalendarUnitDay.

The problem in your case is that you get a warning about abandoning Objective-C instead of Swift. We hope that Apple will fix this soon.

Hope this explains ...

+4
source share

in Xcode 7.3 use .Day, which is a property of the NSCalendarUnit structure

0
source share

All Articles