Search code examples
iosswiftuitextfieldcocoapodsmultiple-inheritance

How to make a UITextField Inherit from two classes?


Some of my UITextFields are inherited from KaedeTextField from TextFieldEffects

I want to make these textfields to have masks from another framework, the AKMaskField

How could that be done? How can I make a textfield have the style of the KaedeTextField but at the same time also have the masks from AKMaskField?

is it possible to do that in Swift using protocols and extensions?


Solution

  • Swift does not support multiple inheritance for classes. Additionally you could conform to a protocol, but since they are both subclasses of the UITextField, there is no reasonable way and frankly - it doesn't make any sense, since they both handle it their own way.

    You would (most likely) end up with a subclass of the first library and then you could recreate a missing feature from the second one.