I'm new programming in Swift and I'm trying to create a form using Eureka Library.
The form is already working but I can't get the data out of the form.
I'm trying to get the data one by one store it into a global variable in order to be printed when the button is pressed.
The thing is the code is always breaking and I don't know how to correct it.
This is my code:
import UIKit
import Eureka
class ViewController: FormViewController
{
//Creating Global Variables
var name: String = ""
var data: Date? = nil
@IBAction func testebutton(_ sender: Any)
{
print(name)
print(data)
}
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
form +++ Section()
<<< TextRow()
{
row in
row.title = "Name"
row.tag = "name"
}
<<< DateRow()
{
$0.title = "Birthdate"
$0.value = Date()
$0.tag = "date"
}
//Gets value from form
let row: TextRow? = form.rowBy(tag: "name")
let nome = row?.value
name = nome!
}
Thanks for your time