因为EKEvent无法容纳额外的属性,所以我正在考虑创建自己的Event类并从EKCalendarItem继承(与EKEvent类相同)。
但是我遇到了FrozenClass错误,这对我来说是很新的。有人知道这意味着什么吗? EKCalendarItem是一个开放类,据我所知我应该能够从中继承。或者...我在这里错了吗?
确切的错误:
'+ [MyApp.Event FrozenClass]:无法识别的选择器已发送给类 0x105667068'
我的代码:
class Event: EKCalendarItem {
// MARK: - Properties
var id: String
var startDate: Date
var endDate: Date
var isAllDay: Bool
// MARK: - Inits
init?(id: String, dictionary: [String: Any]) {
guard
let title = dictionary["title"] as? String,
let startDate = dictionary["startDate"] as? Timestamp,
let endDate = dictionary["endDate"] as? Timestamp,
let isAllDay = dictionary["isAllDay"] as? Bool
else { return nil }
self.id = id
self.startDate = startDate.dateValue()
self.endDate = endDate.dateValue()
self.isAllDay = isAllDay
super.init()
self.location = dictionary["location"] as? String
self.title = title
self.notes = dictionary["notes"] as? String
}
convenience init?(snapshot: QueryDocumentSnapshot) {
self.init(id: snapshot.documentID, dictionary: snapshot.data())
}
}