此更新为我打破了几件事。
以下是代码:
func convertStartAndExpiryDateFromPickerIntoString(datePicker: UIDatePicker) -> String {
let dateFromPicker = datePicker.date
let calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)
let unitFlags = NSCalendarUnit.MonthCalendarUnit | NSCalendarUnit.DayCalendarUnit
let components = calendar.components(unitFlags, fromDate: dateFromPicker)
return "\(months.objectAtIndex(components.month)) \(components.day)"
}
有什么想法吗?
感谢您的时间
答案 0 :(得分:0)
罗布建议工作时解开。
func convertStartAndExpiryDateFromPickerIntoString(datePicker: UIDatePicker) -> String {
let dateFromPicker = datePicker.date
let calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)!
let unitFlags = NSCalendarUnit.MonthCalendarUnit | NSCalendarUnit.DayCalendarUnit
let components = calendar.components(unitFlags, fromDate: dateFromPicker)
return "\(months.objectAtIndex(components.month)) \(components.day)"
}