Hi crew another advice needed on how to make the code more simple ... I have a pickerview with 3 different arrays : 1st is numbers from 1-25 , 2nd and 3rd - string data
Looks something like in the picture below
The first array is used only to multiply in the formula by its value For example When user picks from the pickerviewer something a math formula is executed for example “ 1 mng white “ formula is executed and everything multiplied by *1 , if user picks “2” than everything is multiplied by 2 . But a completely different formula is executed when user picks in the 2nd or 3rd array . What I’ve made is :
‘’’ if self.MyShiftType == "LMNG" , self.MyLevel == "White" { let stavkaNalog = stavka * 11 - stavka * 11 * socialka - ( stavka * 11 - stavka * 11 * socialka ) * incomeTa let matrixTax = performanceBonu * 11 - performanceBonu * 11 * socialka - ( performanceBonu * 11 - performanceBonu * 11 * socialka) * incomeTa let net = stavkaNalog + matrixTax self.result.text = "Your salary: " + (String(format:"%.2f",net * self.shiftnumber)) } “ ‘’’ As you can see I’m checking a condition if myshiftType ==“ LMNG “ , my level= “white “ it’s executes the needed formula , if user picks again LMNG and a different level I need to make again same condition an execute a formula . And here is the problem A LOT OF CODE LINES . tried a switch method but I can’t make it work when I need to select both selections and than execute a code . Is there any solution to simplify the code ?
Aucun commentaire:
Enregistrer un commentaire