0

I Want to Execute countdown timer in swift 2 but it have a issue like Missing argument for parameter options, how to solve this, In swift 1.2 i execute the same code but in swift 2 i cant do it..

In swift 1.2

        let components1 = NSCalendar.currentCalendar().components(.CalendarUnitSecond |
        .CalendarUnitMinute | .CalendarUnitHour | .CalendarUnitDay |
        .CalendarUnitMonth | .CalendarUnitYear, fromDate: UTCDate,
        toDate: date!, options: nil)

In swift 2

let components1 = NSCalendar.currentCalendar().components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date!)

Here Where I want to give toDate in swift 2.

B.Saravana Kumar
  • 1,208
  • 6
  • 20
  • 48

1 Answers1

1

The options parameter in Swift 2 for this method is not an optional anymore so you can't pass nil to it, you have to pass an empty array if you don't want to specify options:

let components1 = NSCalendar.currentCalendar().components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: UTCDate, toDate: date!, options: [])
Eric Aya
  • 69,473
  • 35
  • 181
  • 253