5

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?

Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148
Nico
  • 6,269
  • 9
  • 45
  • 85

3 Answers3

10

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

Schemetrical
  • 5,506
  • 2
  • 26
  • 43
4

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...

Mayur Deshmukh
  • 1,169
  • 10
  • 25
0

in Xcode 7.3 use .Day which is a property of NSCalendarUnit struct

thierryb
  • 3,660
  • 4
  • 42
  • 58