I have created a PickerView in a SegmentControl, I am having two separate array FirstArray has StringData, Second Array has NSNumber data. I need to return both the array in order to return as StringDataand Number in same row.
For Example: First Array has : Ark,silk,temp etc, Second Array has 23,45,56 etc.
If I return the first Array alone in PickerView it was returning String value, but I need both array to be displayed.I am done with displaying one array in picker view but don't know how to return two arrays.
Code:
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if (pickerView == EventsPickerView) {
// case EventsPickerView:
return EventArray.count
}else {
switch FabricSegmentControl.selectedSegmentIndex {
case 0:
return globalConstants.ClassificationName.count
// return globalConstants.ClassificationName.count + globalConstants.ClassificationCount.count
case 1:
return globalConstants.ClassificationNameSecond.count
default:
return 1
}
}
// return 1
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if (pickerView == EventsPickerView){
// case EventsPickerView:
return EventArray[row]
}else {
switch FabricSegmentControl.selectedSegmentIndex {
case 0:
return globalConstants.ClassificationName[row] as? String
case 1:
return globalConstants.ClassificationNameSecond[row] as? String
default:
return "error occured"
}
}
// return "error occured"
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (pickerView == EventsPickerView){
eventTextField.text = EventArray[row]
}else {
switch FabricSegmentControl.selectedSegmentIndex {
case 0:
TypeOfSilkTextField.text = globalConstants.ClassificationName[row] as? String
case 1:
TypeOfSilkTextField.text = globalConstants.ClassificationNameSecond[row] as? String
default:
break
}
}
These are my array Names
First Array :globalConstants.ClassificationName.count
SecondArray name :globalConstants.ClassificationCount.count