All three are in an error state. When I looked into it, it was written that the position of the closing parenthesis was different, but I do not understand well

Error message
Error message
Value of type 'UIDatePicker?' Has no member 'delegate'
### Applicable source code
 self.testPickerView.delegate = self
 self.testPickerView.dataSource = self
 count = dataList [0] [testPickerView.selectedRow (inComponent: 1)] * 60

Enter the language name here

  • Answer # 1

    I don't think

    UIDatePickerhasdelegate. (See the definition of the UIDatePicker class.)
    If testPickerView is changed to UIPickerView, it will be fixed.

    import UIKit
    class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
        @IBOutlet weak var picker: UIPickerView!
        @IBOutlet weak var dater: UIDatePicker! // No delegate!
        override func viewDidLoad () {
            super.viewDidLoad ()
            picker.delegate = self
    //Dater.delegate = self is NG.
            // Do any additional setup after loading the view.
        func numberOfComponents (in pickerView: UIPickerView)->Int {
            return 1 // Set it appropriately.
        func pickerView (_ pickerView: UIPickerView, numberOfRowsInComponent component: Int)->Int {
            return 4 // Set it appropriately.