StoryFlow icon indicating copy to clipboard operation
StoryFlow copied to clipboard

UIViewController not fully instantiated?

Open howlingblast opened this issue 4 years ago • 0 comments

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.

howlingblast avatar May 18 '20 16:05 howlingblast