Changes

Jump to: navigation, search

An Introduction to Swift Subclassing and Extensions

12 bytes removed, 20:34, 1 February 2016
m
Text replacement - "<google>BUY_IOS9</google>" to "<htmlet>ios9</htmlet>"
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>
When using inheritance it is not unusual to find a method in the parent class that almost does what you need, but requires modification to provide the precise functionality you require. That being said, it is also possible you'll inherit a method with a name that describes exactly what you want to do, but it actually does not come close to doing what you need. One option in this scenario would be to ignore the inherited method and write a new method with an entirely new name. A better option is to override the inherited method and write a new version of it in the subclass.
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>
Before proceeding with an example, there are two rules that must be obeyed when overriding a method. Firstly, the overriding method in the subclass must take exactly the same number and type of parameters as the overridden method in the parent class. Secondly, the new method must have the same return type as the parent method.
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>

Navigation menu