Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
mobile ruleP2stack specificStack: ios
iosuikitreadability
Configure UIKit subviews in a property closure, not in setup code
Declare and configure a subview in a lazy/immediately-invoked property closure so its config lives with its declaration instead of scattered in setupUI.
PR: mobile-mining-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | let label = UILabel() |
| 2 | // ...later in setupUI: label.textColor = .white; label.font = ... |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | private let label: UILabel = { |
| 2 | let l = UILabel(); l.textColor = .white; return l |
| 3 | }() |
Explanation (EN)
Objašnjenje (HR)