sgr-ksmt/FormToolbar

Crash due to nil values

Closed this issue · 3 comments

Hello, i was using this library with swift 3, and never had problems. However, when upgrading to swift 4, i noticed a strange issue when using FormToolbar.
Investigating the code i noticed that the buttons were set to nil. This, seems however to cause the crash:

/// Back/Forward button arrow direction
    public var direction: Direction = .upDown {
        didSet {
            switch direction {
            case .upDown:
                backButtonType = .up
                forwardButtonType = .down
            case .leftRight:
                backButtonType = .prev
                forwardButtonType = .next
            }
            backButton = nil
            forwardButton = nil
            fixedSpacer = nil
            updateBarItems()
        }
    }
    
    /// Done button's title
    /// Default is `"Done"`.
    public var doneButtonTitle: String = "Done" {
        didSet {
            doneButton = nil
            updateBarItems()
        }
    }

I ve commented out all the nil assignment and this prevented the app from crashing.
However, i would like to understand the reason of this crash. The problem seems to appear on the method updateBarItems()

I'm sorry for the delay in replying your report.
I just fixed it in #5.

Please update FormToolbar to v1.1

Thank you for the new commit, everything works again!