I\'m a complete beginner on iOS dev and I want to create a little iOS application. On this application, 3 UIPickerViews
are supposed to display different data.
You're comparing instances with tags.
Replace:
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
if pickerView2 == 2 {
return test[row]
} else if pickerView3 == 3{
return test2[row]
}
return ""
}
with:
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
if pickerView2.tag == 2 {
return test[row]
} else if pickerView3.tag == 3 {
return test2[row]
}
return ""
}
Anyway, you don't need to tag your pickers. The pickers come in the datasource and delegate methods. You can compare instances. Something like this:
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
if pickerView2 == pickerView {
return test[row]
}
if pickerView3 == pickerView {
return test2[row]
}
return ""
}