I'm a newbie developer, trying to return 2 variables but without any success. Here are what I have already tried:
I tried to put these 2 variables (I'm not sure if those are variables or they have different name) into the array and then call return, but the error was:
"cannot convert return expression of type [Int] to return type int"
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { var typeAndStoreArray = [Int]() typeAndStoreArray.append(stores.count) typeAndStoreArray.append(types.count) return typeAndStoreArray }I tried to put
stores.countinto variable calledscandtypes.countinto variable calledtc, but here as well I had an errorfunc pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { let sn = stores.count let tn = types.count return (sn, tn) }
Try to understand the functionality of this delegate method.
The method is called multiple times for each component. It passes the index of the component and expects to return the corresponding number of rows.
So if your
storesarray is component 0 andtypesis component 1 you have to write