问题
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?
回答1:
Use .CalendarUnitDay
. NSCalendar is a native Objective-C framework and the error messages aren't for swift.
回答2:
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...
回答3:
in Xcode 7.3 use .Day which is a property of NSCalendarUnit struct
来源:https://stackoverflow.com/questions/29529925/use-of-unresolved-identifier-nscalendarunitday