rspec/rules/S4185/swift/rule.adoc

54 lines
1.2 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
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.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
class VC: UIMyViewController {
override func loadView() {
// ...
super.loadView()
}
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
class VC: UIMyViewController {
override func loadView() {
// ...
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this call to "super.xxx()".
=== Highlighting
``++super.xxx()++``
endif::env-github,rspecator-view[]