import UIKit
class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate { @IBOutlet var picker: UIPickerView! @IBOutlet var label: UILabel!
var Array = ["Iphone", "겔럭시", "베가아이언"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
picker.delegate = self
picker.dataSource = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
return Array[row]
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return Array.count
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
@IBAction func buttonTapped(sender: AnyObject) {
label.text = Array[row] ///this part error "use of unresolved identifier row"
}
}
could you explain to me the difference between the error row and row that I used for title above?
why I would get error for the bottom one. I declare correctly I think.