Skip to content

UIViewController not fully instantiated? #11

@howlingblast

Description

@howlingblast

Hi there,

while I would love this little gem of a framework to work, I can't get it to work with the smallest example.

I created a new project (Xcode 11, basic singe view app for iOS) added a second view controller and followed the instructions found in the lightning talk https://www.youtube.com/watch?v=mtBBlml759k.

Unfortunately I will end with

Unexpectedly found nil while implicitly unwrapping an Optional value

in the second view controller (line #26 outputLabel.text = input).

It seems to me that the second view controller is not fully instantiated. I tried with a xib file to no avail.

Any hints what I'm doing wrong? Am I missing something?

A small example would work wonders. Thanks for the novel approach.

MainViewController.swift

import UIKit
import StoryFlow

class ViewController: UIViewController, OutputProducing {
    typealias OutputType = String

    @IBOutlet weak var inputTextField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBAction func buttonTapped(_ sender: Any) {
        produce(inputTextField.text ?? "")
    }
}

SecondViewController.swift

import UIKit
import StoryFlow

class SecondViewController: UIViewController, InputRequiring {

    typealias InputType = String

    @IBOutlet weak var outputLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        outputLabel.text = input
    }
}

Both view controller are within the default storyboard. Verified class for the second.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions