mercredi 17 juillet 2019

conditions or if statements in pickerview

i need really help with making the logic here , so i've got 3 different arrays that i use in my PICKERVIEW .when user selects something like this in a pickerview a certain formula should execute (its not relevant which it is) what should i use ? if statements? switch ? and one more question . will the shiftCount array data that is used as string be a problem ? cuz i need to then multiply the formula by *1 or *2 and etc.

   var shiftCount = [
   "1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25"]

   var Level = [
       "White","Silver 80%","Silver 100%","Gold 80%","Gold 100%","Diamond 80%","Diamond 100%",]

   var shiftDay = [

   "MNG","LMNG","AFT","LAFT","PEAK","LNGT","NGT"]

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {


        switch (component) {
        case 0:
            MyShifts = shiftCount[row]
            shifts.text = "How many shifts: " + MyShifts
            print(MyShifts)
        case 1:
            MyShiftType = shiftDay[row]
            shiftType.text = "Shift you work: " + MyShiftType
            print(MyShiftType)
        case 2:
            MyLevel = Level[row]
            level.text = "Your Level: " + MyLevel
            print(MyLevel)
        default:
            break
        } 

Aucun commentaire:

Enregistrer un commentaire