IBOutlet Private
ID |
swift.iboutlet_private |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Swift |
Tags |
code-smell, encapsulation |
Description
Reports an @IBOutlet property that isn’t declared private or
fileprivate. Outlets are wiring between the storyboard and the view
controller — external callers should not touch them.
@IBOutlet var label: UILabel! // FLAW
@IBOutlet private var label: UILabel! // OK
@IBOutlet fileprivate var label: UILabel! // OK
Rationale
A public outlet leaks internal layout structure into the view controller’s public API and tempts callers to mutate it directly, defeating the controller’s encapsulation.