I have created a class
class NewTabContainerModal {
var newContainerDate = Date()
var newContainerSelectedFilter : NewAllErrorFIlter = .Yearly
func resetModal () {
newContainerSelectedFilter = .Yearly
newContainerDate = Date()
}
}
I have created an enum to get the values from it
enum NewAllErrorFIlter : String {
case Monthly = "2"
case Yearly = "1"
case Daily = "3"
}
Now in my ViewController class I have created a variable
var newContainerModal: NewTabContainerModal?
And in viewWillAppear I am trying to print the value of the enum like this
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let newContainerModelData = newContainerModal?.newContainerSelectedFilter
print(newContainerModelData)
}
but it is giving me nil instead of yearly value. I don't understand what I am doing wrong. Please help?
Its because
newContainerModal
in your Viewcontroller isnil
sonewContainerModal?.newContainerSelectedFilter
also gonna be anil
change it withIn addition
will print
Yearly
. to get that value usenewContainerModelData.rawValue