I'm trying to create a Eureka form for editing / creating a task object. Now, I segue to the view and pass on a Task object as class variable, but for some reason it is not accessible from viewDidLoad where I'm creating the form. This means I can't assign values to the form. When I create a didSet method for the Task class variable, it gets called eventually, but then the form object is an empty object, as when I look form.values() there is nothing. But in viewDidLoad it works. Any suggestions what am I missing?
var task: Task? { didSet { print("didSet values:", form.values(), "didSet task name", task?.name) } }
override func viewDidLoad() {
super.viewDidLoad()
form +++ Section()
<<< TextRow("name"){
$0.title = "Name"
}
print("viewDidLoad values:", form.values(), "viewDidLoad task name", task?.name)
}
and output
viewDidLoad values: ["name": nil, "deadline": Optional(2017-06-08 19:02:39 +0000)] viewDidLoad task name nil
didSet values: [:] didSet task name Optional("ascasc")
Well, after debugging I found that there were two different instances of the Eureka form view. So after digging I found that I did two segues doing the same thing. One segue from storyboard tableView cell to the form, and other from code by didSelectRowAt and performSegue. Interesting that I didn't find this when I debugged the prepare(for segue:) from the controller which called the form view, it should have printed the output twice, but I saw only one, so I was always thinking I was creating only one segue.