xmartlabs / Eureka

Elegant iOS form builder in Swift
https://eurekacommunity.github.io
MIT License
11.77k stars 1.33k forks source link

swift_dynamicCastUnknownClassUnconditional exception when trying to work with OptionsProvider #1327

Closed max-pfeiffer closed 6 years ago

max-pfeiffer commented 6 years ago

I am trying to get my custom row/viewcontroller to work with V4.0.1. Problem is that there is no row.dataProvider any more.

Looking at the source code I learned about the new OptionsProvider in SelectorViewController.

However I tried to pull the option in my class to use it like this (as it is done inSelectorViewController):

 public var optionsProviderRow: OptionsRow {
        return row as! OptionsRow
 }

open func setupForm() {
        let optProvider = optionsProviderRow.optionsProvider
        optProvider?.options(for: self) { [weak self] (options: [Row.Cell.Value]?) in
            guard let strongSelf = self, let options = options else { return }
            strongSelf.optionsProviderRow.cachedOptionsData = options
            strongSelf.setupForm(with: options)
        }
 }

This is giving me a swift_dynamicCastUnknownClassUnconditional exception in the runtime of my app. Source code compiles fine.

Any hints how and work with OptionsProvider and it's contents is highly appreciated. I just spend hours not able to solve the problem.

max-pfeiffer commented 6 years ago

Ok, I found a workaround for my custom row and viewController with UISearchbar. See my gist: https://gist.github.com/max-pfeiffer/cd823549653ae22b8ba600b6cc4c764b

It might be of some use for other programmers maintaining custom viewcontrollers. If anyone finds a proper solution for using the optionsprovider please drop me a line.