Reputation: 1402
Xcode error: Type of expression is ambiguous without more context
How do I fix it?
let componentss = calendar.components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: date)
Upvotes: 2
Views: 3994
Reputation: 1402
Thanks it works!
dateFormat.dateStyle = NSDateFormatterStyle.ShortStyle
dateFormat.timeStyle = NSDateFormatterStyle.ShortStyle
datePicker.datePickerMode = UIDatePickerMode.DateAndTime
datePicker.addTarget(self, action: Selector("updateDateField:"),forControlEvents:UIControlEvents.ValueChanged)
yearLabel.inputView = datePicker
How do I convert this to dd-MM-yyyy H:mm:ss ?
Upvotes: 0
Reputation: 93161
CalendarUnit
name has changed in Swift 2.0. Try this:
let componentss = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date)
Upvotes: 6