问题描述
我已经使用 swift 包管理器在我的项目中添加了 CalendarKit,我也尝试过使用 cocoapods,但仍然出现以下错误:
我还添加了 import CalendarKit
。
1) 'Date' 类型的值没有成员 'format'
let timezone = TimeZone.ReferenceType.default
var info:[String] = ["Booking Id: \(bookingDetails.bookingID ?? -1)","Booking Type: \(bookingDetails.bookingType!)"]
info.append("Booking From : \(begining.format(with: "dd.MM.YYYY",timeZone: timezone)) \nBooking To : \(ending.format(with: "dd.MM.YYYY",timeZone: timezone))")
info.append("Timing: \(begining.format(with: "HH:mm")) - \(ending.format(with: "HH:mm"))")
info.append("Status: \(status)\n")
2) 'Date' 类型的值没有成员 'hours'
if indexPath.section == 1 {
selectedbookingRecord = self.upcomingBookings![indexPath.row] as BookingInfoList
if let bookingStartDateTime = selectedbookingRecord?.bookingFrom {
if (bookingStartDateTime.toDate()?.hours(from: Date()))! < 24 {
dispatchQueue.main.async {
Alert().showAlert(ALERT_TITLE,message: GlobalConstants.CANNOT_DELETE_BOOKING,okButtonTitle: ALERT_OK_TITLE,CompletionHandler: nil,View: self)
}
return
}
}
}
提前致谢!
解决方法
所提供的代码似乎是使用旧版本的 CalendarKit
开发的,该版本依赖于 DateToolsSwift
。现在,删除依赖项后,您提供的代码无法编译。
为了解决您的问题,请使用旧版本的 CalendarKit(不大于 0.14.0
,例如 0.13.14
就可以了),
或者,只需将 DateTools 独立安装并导入到您使用该框架的文件中。