From 474d6f4f5c0078cc560952de03d0c98edde27da2 Mon Sep 17 00:00:00 2001 From: thanhlong12312 Date: Tue, 9 Apr 2019 07:38:56 +0700 Subject: [PATCH] fix_didselectedrow (#48) --- McPicker/Classes/McPicker.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/McPicker/Classes/McPicker.swift b/McPicker/Classes/McPicker.swift index 826b193..32396cf 100644 --- a/McPicker/Classes/McPicker.swift +++ b/McPicker/Classes/McPicker.swift @@ -439,8 +439,10 @@ extension McPicker : UIPickerViewDelegate { } public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - self.pickerSelection[component] = pickerData[component][row] - self.selectionChangedHandler?(self.pickerSelection, component) + if component < pickerSelection.count { + self.pickerSelection[component] = pickerData[component][row] + self.selectionChangedHandler?(self.pickerSelection, component) + } } }