UIPickerViewDelegate bug

Hi, I'm writing a code with a UIPickerView that has 3 components. I want each component to have a different row height. Obviously I tried to use pickerView(_:rowHeightForComponent:), but it turns out that rowHeightForComponent sometimes equals to the number of components, i.e. in my case is sometimes equals 3. So I actually get a component index that is not valid. Did anyone have the same problem? Is it a known bug?

This is the code of the method:

    func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
        componentsRowHeight[component]
    }

Because I have 3 components, which are held in an array, the valid indices are 0, 1, 2. But the delegate function is sometimes called with 3.

Could you show the code ?

rowHeightForComponent sometimes equals to the number of components, i.e. in my case is sometimes equals 3

Those two items (row height and number of components) are completely different in nature (and one is CGFloat, other Int). What do you mean precisely ?

I mean that the method is called with the parameter component which is out of bounds. In the docs for this method apple states in regards to component:

A zero-indexed number identifying a component of pickerView. Components are numbered left-to-right.

So the actual number, in my case which I have 3 components. The number of components is returned from

func numberOfComponents(in pickerView: UIPickerView) -> Int {
  3
}

that I implement as part of the data source.

Added.

UIPickerViewDelegate bug
 
 
Q