Handling non-optional optionals in Swift
John Sundell
2298

  1. The first force unwrapping could also be avoided by using a local variable:
    let tableView = UITableView()
    self.tableView = tableView
    view.addSubview(tableView)
  2. The Null Object Pattern is also a good way to avoid optionals alltogether: https://medium.com/swift-programming/null-object-pattern-in-swift-1b96e03b2756
Show your support

Clapping shows how much you appreciated Fabian’s story.