Eureka: Unexpected nil optional on Swift 4.

Created on 25 Jun 2017  路  1Comment  路  Source: xmartlabs/Eureka

My apologies, it looks like the boilerplate text expects me to use only the stable Xcode and Swift, but I figured I'd report this for the Swift 4 branch on Xcode 9 Beta 2.

Simply put, Eureka doesn't work at all. The moment you try to show a FormViewController, your app crashes.

unexpectedly found nil while unwrapping an Optional value

When it crashes, you are taken to this line on Core.swift which doesn't seem to be force unwrapping optionals:

    open override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        animateTableView = true
        let selectedIndexPaths = tableView.indexPathsForSelectedRows ?? []

So I'm not quite sure what's going on here. My form is this one:

/// View controller to add a new server.
class NewServerTableViewController: FormViewController {
    // MARK: Initializers
    /// Initializes a ServersTableViewController instance.
    init() {
        super.init(style: .plain)
        title = NSLocalizedString("Servers", comment: "")
    }

    /// Initializes a view controller with a coder.
    /// - parameter coder: Coder to use.
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }

    // MARK: - Overrides

    override func viewDidLoad() {
        form +++ Section("Section1")
            <<< TextRow(){ row in
                row.title = "Text Row"
                row.placeholder = "Enter text here"
            }
            <<< PhoneRow(){
                $0.title = "Phone Row"
                $0.placeholder = "And numbers here"
            }
            +++ Section("Section2")
            <<< DateRow(){
                $0.title = "Date Row"
                $0.value = Date(timeIntervalSinceReferenceDate: 0)
        }
    }

    /// Creates the first section.
    func prepareFirstSection() {

    }
}

And it's getting pushed by a navigationController like this:

    @objc func addNewServerAction(sender: UIBarButtonItem) {
        let newServerTvc = NewServerTableViewController()
        navigationController?.pushViewController(newServerTvc, animated: true)
    }

Thought it also happens when I present it modally.

Most helpful comment

Got it, gotta call super.viewDidLoad()

>All comments

Got it, gotta call super.viewDidLoad()

Was this page helpful?
0 / 5 - 0 ratings