I have the following code in Swift 1.2 :
//Age
@IBOutlet weak var daysLabel: UILabel!
@IBOutlet weak var monthsLabel: UILabel!
@IBOutlet weak var yearsLabel: UILabel!
@IBAction func birthday(sender:AnyObject){
var dateComponents = NSDateComponents()
dateComponents.day = 19
dateComponents.month = 12
dateComponents.year = 1999
let birthDate = NSCalendar(identifier: NSCalendarIdentifierGregorian)!.dateFromComponents(dateComponents)!
let durationDateComponents = NSCalendar(identifier: NSCalendarIdentifierGregorian)!.components( [.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: birthDate, toDate: NSDate(), options: nil)
yearsLabel.text = "\(durationDateComponents.year)"
monthsLabel.text = "\(durationDateComponents.month)"
daysLabel.text = "\(durationDateComponents.day)"
}
and this used to display how many days their were to my birthday but this doesn't seem to be working in Swift 2. I get an error at
let durationDateComponents = NSCalendar(identifier: NSCalendarIdentifierGregorian)!.components( [.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: birthDate, toDate: NSDate(), options: nil)
saying "nil isn't compatible with an argument of NSCalenderOptions.