I'm working on a table view where I want to use the UITableViewHeaderFooterView class to customzie my headers and reuse them for several sections in the table. I am trying to understand what the logic for this code is:
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
}From the reference docs, I understand what the method does, what I don't understand is the line of of code inside the method
super.init(reuseIdentifier: reuseIdentifier)I've seen this from time to time as I have been learning iOS development, any explanation of what super.init is doing would help. It seems redundant, but perhaps because I don't understand the logic begind this.
Thanks!
It's an initializer, which is used to create and initialize instances of your UITableViewHeaderFooterView subclass. Since it is a class (rather than a struct), it has a superclass (parent class) from which it can inherit behavior.
The rules of Swift require that subclass initializers must invoke a superclass initializer. That's to give the superclass's internal logic a chance to initialize its own properties.
I suggest you work your way through this section of the Swift documentation:
developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html
It's likely more detailed than you want right now, but it's worth your while to spend a bit of effort on it.