I keep getting the error "Definition Conflicts With Previous Value" this error has only shown up the most recent time I opened XCode previously my code was working correctly and running allowing me to the the UITextField with the pickerView input view.
import UIKit
class FormViewController: UIViewController, UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate {
@IBOutlet weak var timeTakenField: UITextField!
let pickerView = UIPickerView()
var options = ["1","2","3","4","5"]
override func viewDidLoad() {
super.viewDidLoad()
pickerView.delegate = self
timeTakenField.inputView = pickerView
}
// MARK: UIPickerView
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return options.count
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return options[row]
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
timeTakenField.text = options[row]
}
This is all the code relating to my picker view and the error is showing on the final two pickerView functions. I have checked all the code and it all seems correct to me I just cant seem to find the source of this error.
Any help will be greatly appreciated thanks.
Aucun commentaire:
Enregistrer un commentaire