rspec/rules/S4184/swift/rule.adoc

49 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Marking a variable with ``++IBOutlet++`` allows it to be connected with a Storyboard component through the Interface Builder. Allowing such a variable to be accessed outside the class, may result in other classes making assignments that override the automatic dependency injection from the Storyboard itself.
=== 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
----
@IBOutlet var label: UILabel! // Noncompliant
----
=== 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
----
@IBOutlet private var label: UILabel!
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Make this "IBOutlet" variable private.
=== Highlighting
variable declaration
'''
== Comments And Links
(visible only on this page)
=== on 5 Sep 2017, 18:56:31 Ann Campbell wrote:
I've made some small edits [~carlo.bottiglieri], but not substantially changed your meaning, I think.
=== on 6 Sep 2017, 10:17:52 Carlo Bottiglieri wrote:
Thanks a lot [~ann.campbell.2]
endif::env-github,rspecator-view[]