1

I have @IBOutlet var heading of type UILabel in base class, now I subclassed this and in the new class I want to have @IBoutlet heading of type MyLabel (let's say I have a class MyLabel subclassed from UILabel). So the question is: how to override the same property to different compatible class?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ajay Kumar
  • 1,807
  • 18
  • 27

1 Answers1

0

There is no way to override property with different type. You can change a class of this property in the Interface Builder and make another property with needed class:

@IBOutlet override var label: UILabel!

private var myLabel: MyLabel? {
    return label as? MyLabel
}
Ilya Kharabet
  • 4,203
  • 3
  • 15
  • 29