rspec/rules/S4185/swift/rule.adoc

33 lines
895 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
It is often considered good practice at the end of an override to invoke ``++super++``, but there are cases where according to the Apple developer documentation this should not be done.
* ``++updateLayer++`` - optimize the rendering of your view
* ``++loadView++`` - provide a ``++view++`` when ``++view++`` is ``++nil++``
* ``++providePlaceholder++`` - provide a placeholder for a document returned by the Document Picker but not yet stored locally
In all cases, these are actions that should happen once and only once. Subsequently invoking ``++super++`` would see your desired result replaced (at best) by less specialized results.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
class VC: UIMyViewController {
override func loadView() {
// ...
super.loadView()
}
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
class VC: UIMyViewController {
override func loadView() {
// ...
}
}
----