Use of unresolved identifier NSCalendarUnitDay
Asked Answered
M

3

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?

Mufti answered 9/4, 2015 at 4:41 Comment(0)
F
10

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

Falconry answered 9/4, 2015 at 4:49 Comment(1)
"updated" is kind of a broad statement. The error message is intended for Objective-C where it's correct.Kelwunn
B
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...

Bluepencil answered 9/4, 2015 at 4:57 Comment(0)
A
0

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

Avner answered 2/5, 2016 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.