Xcode错误:表达式的类型不明确,没有更多的上下文
我该如何解决?
let componentss = calendar.components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: date)
答案 0 :(得分:6)
CalendarUnit
名称已更改。试试这个:
let componentss = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date)
答案 1 :(得分:0)
谢谢它有效!
dateFormat.dateStyle = NSDateFormatterStyle.ShortStyle
dateFormat.timeStyle = NSDateFormatterStyle.ShortStyle
datePicker.datePickerMode = UIDatePickerMode.DateAndTime
datePicker.addTarget(self, action: Selector("updateDateField:"),forControlEvents:UIControlEvents.ValueChanged)
yearLabel.inputView = datePicker
如何将其转换为 dd-MM-yyyy H:mm:ss ?