Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'DayCalendarUnit was deprecated. Use NSCalendarUnitDay instead' doesn't work [duplicate]

let dateComponents = calendar.components(.DayCalendarUnit | .MonthCalendarUnit | .YearCalendarUnit, fromDate: date)  

I got error:

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

But when I replace these names with those suggested by Apple

let dateComponents = calendar.components(NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear, fromDate: date)

I get error:

Use of unresolved identifier 'NSCalendarUnitDay' 
like image 589
Bartłomiej Semańczyk Avatar asked Apr 09 '15 10:04

Bartłomiej Semańczyk


1 Answers

Along with latest Swift 2.0:

NSCalendarUnit.Day

hence you will now have:

let dateComponents = calendar.components([NSCalendarUnit.Month, NSCalendarUnit.Day, NSCalendarUnit.Year], fromDate: date)
like image 152
Bartłomiej Semańczyk Avatar answered Oct 28 '22 12:10

Bartłomiej Semańczyk