Post

Replies

Boosts

Views

Activity

Reply to Reset Values After A Calculation + Picker Selection
OOPer, Found the issue. It had to do with a typo within my "guard" segments. I was missing the selectedRow2 on the second guard statement. Thanks again for the help! Changed it to:      let selectedRow = picker.selectedRow(inComponent: 0)     guard data.indices.contains(selectedRow) else {       print("selectedRow invalid")       return     }     fv = data[selectedRow].fv           let selectedRow2 = pickerCyl.selectedRow(inComponent: 0)     guard data2.indices.contains(selectedRow2) else {       print("selectedRow invalid")       return     }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Reset Values After A Calculation + Picker Selection
OOPer, Thanks again for the help. In introduced that code and it works for everything except on my first picker, after I scroll past the first two options, it gives me an "selectedRow Invalid" in the debugger window. I think it has something to do with the fact that my second picker only has two options, so it's only letting me select two options in the first picker as well. Any other options after the first two ("Aluminum 100" and "Aluminum 80") gives me the "selectedRow Invalid". I'm not sure if this is some unintended interaction between my picker functions? I thought under    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) - Int {     switch pickerView.tag {     case 1:       return data.count     case 2:       return data2.count     default:       return 1     }   } } It would properly initialize both pickers separately.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Picker View Data used elsewhere
OOPer, Really appreciate the help; that did the trick. My brain wasn't registering that I had defined the data in an array and wouldn't be able to change it. Thank you! Claude31, Thanks for the advice on avoiding crashes. I hadn't got that yet, but that was going to be information I was also going to have to hunt down.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21