1

I have created custom tableViewCell,and I don't understand why do i need to init it 2 times , override init and super.init ,what this code does, please explain

class tablecell: UITableViewCell {
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
    }
}
Bista
  • 7,869
  • 3
  • 27
  • 55
Ninja13
  • 883
  • 1
  • 6
  • 9
  • If you are not doing anything in the init, you can ignore the method. From the code you are actually doing nothing in that method anyways. – Sachin Vas Oct 06 '16 at 04:52

1 Answers1

1

This: super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) doesn't mean you are initing two times.

super allows us to use the defaults of the table view cell with our custom code to work with.

So super says that: I'll use my own code with defaults.

More info: What exactly is super in Objective-C?

Community
  • 1
  • 1
Bista
  • 7,869
  • 3
  • 27
  • 55