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
PublicDomainObject
subclass ofMuseumObject
. - It has a property —
primaryImageSmall
— that isn’t in the parent class, so you defined itsinit
method to set this property and call the parent’sinit
. - You redefined
showImage()
, then called this method from aMuseumObject
and from aPublicDomainObject
. - Each object behaved according to its type: The
MuseumObject
usedSFSafariViewController
, and thePublicDomainObject
usedMuseumObjectView