Subclassing vs Extension in swift -
i want customise 1 uitextfield reason. subclassed , added few methods.
instead of can use extension on uitextfield ? approach ? please explain !
as general rule of thumb (ymmv):
- are adding general-purpose functionalities should available every
uitextfield
? if so, make extension.uitextfield
instances can call new methods. - are adding functionality should restricted special instances of
uitextfield
identify precisely? if so, make subclass. instances of subclass can use new methods.
there other technical considerations, extensions can't add fields, instance.
Comments
Post a Comment