Extending library classes anti-pattern?
This video tells about extending UIKit classes. Isn't extending framework classes considered to be an antipattern, and encapsulation the recommended approach?
Caleb KleveterTreehouse Moderator 37,862 Points
No. Extending or subclassing a type from an outside framework is perfectly acceptable and a very common thing to do. I would go so far as to say it is preferred over encapsulation.
I personally don't do a lot of iOS development or use sub-classing (I use Swift for other things), so I'm not going to get into how it all works, but you might find the UIKIt documentation to be helpful.
Ok thank's, I'll prob get the picture when I proceed with the Swift courses.
It's simpler for sure to extend a class. I guess when dealing with UIKit classes there's little point in hiding any functionality since you don't typically know beforehand exactly which methods and properties you'd want? I mean, if there's a class where I want to use only a small fraction of the valuable methods & attribute, I could choose to use an interface to that utility class instead and implement only what I need.