open class CheckItem<T, U: Equatable & CustomStringConvertible>: DataTableItem<T,U,Bool> {
public override init(_ data: T, getter: @escaping (T) -> U) {
super.init(data, getter: getter)
}
}
open class DataTableItem<T, U: Equatable & CustomStringConvertible, V: CustomStringConvertible>: TableItem{
let data: T
let getter: (T) -> U
public init(_ data: T, getter: @escaping (T) -> U) {
self.data = data
self.getter = getter
}
}
open class TableItem: NSObject {
public var title: String?
}
It is weird that, can't override the init in subclass CheckItem.
Compiler complains that Initializer does not override a designated initializer from its superclass. It complains that Overriding declaration requires an 'override' keyword if I remove the override keyword.
It drives me crazy anyone helps? Thanks in advance.
The more weird part is that it works in LabelItem
open class LabelItem<T, U: Equatable & CustomStringConvertible, V: CustomStringConvertible>: DataTableItem<T,U,V>{
public override init(_ data: T, getter: @escaping (T) -> U) {
super.init(data, getter: getter)
}
The full code is available here https://github.com/magerate/TableMaker
Edit
let checkItem = CheckItem<People, Bool>(people, getter: {(p: People) -> Bool in
p.isGirl
})
It compiles if don't try to create any instance of CheckItem. But complains
Cannot convert value of type 'People' to expected argument type 'Bool'
when try to create a new instance of CheckItem.
It seems that type inference is not correctly here.
Edit
It works when I deploy the code to swift framework. WTF