Conclusion
Let’s sum up what you learnt in this lesson:
- Inheritance and polymorphism enable you to create flexible, reusable code.
- In this lesson, you created a
PublicDomainObjectsubclass ofMuseumObject. - It has a property —
primaryImageSmall— that isn’t in the parent class, so you defined itsinitmethod to set this property and call the parent’sinit. - You redefined
showImage(), then called this method from aMuseumObjectand from aPublicDomainObject. - Each object behaved according to its type: The
MuseumObjectusedSFSafariViewController, and thePublicDomainObjectusedMuseumObjectView