Pattern: Use of implicitly unwrapped optional
Issue: -
Implicitly unwrapped optionals should be avoided when possible.
Examples of correct code:
@IBOutlet private var label: UILabel!
@IBOutlet var label: UILabel!
@IBOutlet var label: [UILabel!]
if !boolean {}
let int: Int? = 42
let int: Int? = nil
Examples of incorrect code:
let label: UILabel!
let IBOutlet: UILabel!
let labels: [UILabel!]
var ints: [Int!] = [42, nil, 42]
let label: IBOutlet!
let int: Int! = 42
let int: Int! = nil
var int: Int! = 42
let int: ImplicitlyUnwrappedOptional<Int>
let collection: AnyCollection<Int!>
func foo(int: Int!) {}