如何解决iPhone应用程序中未知的预期错误

时间:2013-05-15 04:53:55

标签: objective-c

我正在通过计算为var分配一个值,但它显示语法错误我已经看到所有括号仍然给出错误,这里是我的代码。

  

appDelegate.Same_Vaccination_Cost_Treatment_Annually_With_Guarantee =((appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee    - 5000)/ appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee)*   ((appDelegate.Cost_Treatment_SevereEI *   appDelegate.Same_Vaccination_SevereEI_Annually)+   (appDelegate.Cost_Treatment_ModerateEI *   appDelegate.Same_Vaccination_ModerateEI_Annually)+   (appDelegate.Cost_Treatment_MildEI *   appDelegate.Same_Vaccination_MildEI_Annually))))*   appDelegate.Same_Vaccination_Horses_Per_Premise;

3 个答案:

答案 0 :(得分:0)

根据您的代码: -

    float Same_Vaccination_Cost_Treatment_Annually_With_Guarantee;
    float Cost_Treatment_SevereEI;
    float Same_Vaccination_SevereEI_Annually;
    float Cost_Treatment_MildEI;
    float Same_Vaccination_MildEI_Annually;
    float Same_Vaccination_Horses_Per_Premise;
    float Same_Vaccination_Cost_Treatment_Annually_No_Guarantee;
    float Cost_Treatment_ModerateEI;
    float Same_Vaccination_ModerateEI_Annually;

Same_Vaccination_Cost_Treatment_Annually_With_Guarantee=(((Same_Vaccination_Cost_Treatment_Annually_No_Guarantee - 5000) / Same_Vaccination_Cost_Treatment_Annually_No_Guarantee) * (((Cost_Treatment_SevereEI * Same_Vaccination_SevereEI_Annually) + (Cost_Treatment_ModerateEI * Same_Vaccination_ModerateEI_Annually) + (Cost_Treatment_MildEI * Same_Vaccination_MildEI_Annually)) * Same_Vaccination_Horses_Per_Premise));

你也可以把方法放在: -

Same_Vaccination_Cost_Treatment_Annually_With_Guarantee=((Same_Vaccination_Cost_Treatment_Annually_No_Guarantee - 5000) / Same_Vaccination_Cost_Treatment_Annually_No_Guarantee) * ((Cost_Treatment_SevereEI * Same_Vaccination_SevereEI_Annually) + (Cost_Treatment_ModerateEI * Same_Vaccination_ModerateEI_Annually) + (Cost_Treatment_MildEI * Same_Vaccination_MildEI_Annually)) * Same_Vaccination_Horses_Per_Premise;

答案 1 :(得分:0)

如果您使用完全相同的

    appDelegate.Same_Vaccination_Cost_Treatment_Annually_With_Guarantee=((appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee - 5000) / appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee) * ((appDelegate.Cost_Treatment_SevereEI * appDelegate.Same_Vaccination_SevereEI_Annually) + (appDelegate.Cost_Treatment_ModerateEI * appDelegate.Same_Vaccination_ModerateEI_Annually) + (appDelegate.Cost_Treatment_MildEI * appDelegate.Same_Vaccination_MildEI_Annually)))) * appDelegate.Same_Vaccination_Horses_Per_Premise;

然后你有2个额外的支撑

    appDelegate.Same_Vaccination_Cost_Treatment_Annually_With_Guarantee=((appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee - 5000) / appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee) * ((appDelegate.Cost_Treatment_SevereEI * appDelegate.Same_Vaccination_SevereEI_Annually) + (appDelegate.Cost_Treatment_ModerateEI * appDelegate.Same_Vaccination_ModerateEI_Annually) + (appDelegate.Cost_Treatment_MildEI * appDelegate.Same_Vaccination_MildEI_Annually)) * appDelegate.Same_Vaccination_Horses_Per_Premise;

答案 2 :(得分:0)

appDelegate.Same_Vaccination_Cost_Treatment_Annually_With_Guarantee =((appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee - 5000)/ appDelegate.Same_Vaccination_Cost_Treatment_Annually_No_Guarantee)*((* appDelegate.Cost_Treatment_SevereEI appDelegate.Same_Vaccination_SevereEI_Annually)+(appDelegate.Cost_Treatment_ModerateEI * appDelegate.Same_Vaccination_ModerateEI_Annually)+(appDelegate.Cost_Treatment_MildEI * appDelegate.Same_Vaccination_MildEI_Annually ))* appDelegate.Same_Vaccination_Horses_Per_Premise;

这会奏效。你使用了太多括号。