使用未parsing的标识符NSCalendarUnitDay

我只是更新到其6.3版本的Xcode。

除了(主要)我必须做的所有修复之外,我还有一些警告刚刚出现(从iOS 8.0开始,这很奇怪)。

我的代码

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

现在显示警告

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

好的,我会通过NSCalendarUnitDay更改NSCalendarUnitDay

现在我得到一个错误说:

 Use of unresolved identifier 'NSCalendarUnitDay' 

我很迷惑,有人可以解释我什么是错的,如何解决?

使用.CalendarUnitDay 。 NSCalendar是一个原生的Objective-C框架,错误消息不适用于swift。

我认为苹果公司认为这些单位的名称没有像DayDaleCalendarUnit那样有意义,所以他们修改了它,听起来像.CalendarUnitDay更为合理和解释性。

在Objective-C中做了类似的修改。 NSDayCalendarUnit被弃用,你必须使用NSCalendarUnitDay。

在你的情况的问题是,你正在接受弃用警告Objective-C而不是Swift。 我们希望苹果很快就能修好。

希望解释…

在Xcode 7.3中使用.Day这是NSCalendarUnit结构的一个属性