ios - Class extension vs. subclassing in Swift? -
i'am using third-party framework provides class instances have properties. in app, i'd add property instances. appropriate way scenario?
a) extending framework's class in app
b) creating subclass of framework's class , define new property need
thanks in advance
it's
b)
because adding (stored) properties in class extension not supported.
there 2 important rules using extensions:
extensions can add new functionality type, cannot override existing functionality
extensions can add new computed properties, cannot add stored properties, or add property observers existing properties
Comments
Post a Comment