I have a simple class:
class TableItem {
class func cellIden() -> String {
return "TableItem"
}
}
and a subclass of TableItem
class EditableItem {
override class func cellIden() -> String {
return "EditableItem"
}
}
Then, somewhere in my code, I have this:
var items: [TableItem] = [TableItem(), EditableItem()]
Now, what I want to do is, iterate through items and call each TableItem
's static cellIden()
function.
for i in items {
var iden = i.self.cellIden()
}
However, it tells me TableItem does not have a member called 'cellIden'
How can I call the static method of a class from its instance?
Note: I can't call TableItem.cellIden()
because i
can be a TableItem
or an EditableItem