2

I am using swift2.

I used this code:

let calendar = NSCalendar.currentCalendar()             
let components = calendar.components(.CalendarUnitMonth | .CalendarUnitDay, fromDate: theDate) 

I am getting this error: Could not find member 'CalendarUnitMonth

Pikamander2
  • 7,332
  • 3
  • 48
  • 69
user2991638
  • 111
  • 1
  • 6

1 Answers1

10

Check Swift 2 documentation and search for OptionSetType (adopted by NSCalendarUnit). You can use it in this way:

let calendar = NSCalendar.currentCalendar()
let components = calendar.components([.Month, .Day], fromDate:NSDate())
zrzka
  • 20,249
  • 5
  • 47
  • 73