let dateComponents = calendar.components(.DayCalendarUnit | .MonthCalendarUnit | .YearCalendarUnit, fromDate: date)
我收到了错误:
'DayCalendarUnit' was deprecated in iOS version 8.0: Use NSCalendarUnitDay instead
但是当我用Apple建议的名称替换这些名字时
let dateComponents = calendar.components(NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear, fromDate: date)
我收到错误:
Use of unresolved identifier 'NSCalendarUnitDay'
答案 0 :(得分:17)
与最新的Swift 2.0一起:
svn
因此你现在将拥有:
NSCalendarUnit.Day
答案 1 :(得分:16)
试试这个
NSCalendarUnit.CalendarUnitDay
答案 2 :(得分:2)
最新的Swift仅适用于.day
,.month
等。