I have a enum like this, it contains different initial states:
enum InitialState {
case listTableView(ListTableViewState)
}
I want to use them like this:
var tableViewState: ListTableViewState?
let test = ListTableViewState(group: .large, statIntervalBase: StatIntervalBaseModel(stat: "ppc", interval: "24h", base: "usd"), order: .ascending, searchParameter: "", quantityStats: .six)
let test1 = InitialState.listTableView(test)
tableViewState = loadInitialState(inital: test1)
This is the generic function I am using:
func loadInitialState<T>(inital: InitialState) -> T {
let test = inital as! T
print(test)
return test
}
I get this error of course:
Could not cast value of type 'InitialState' (0x109466da0) to 'ListTableViewState' (0x1094912b0).
How can I access it in the generic function loadInitialState
?