-3

我有以下代码:

if (condition1)
{
   if (condition2)
   {
      Do sth.
   }
   else if (condition3)
   {
      Do sth.
   }
   else
   {
      // get back to check condition4.
   }
}
else if (condition4)
{
   Do sth.
}
4

2 回答 2

2
if (condition1 && (condition2 || condition3))
{
    if (condition2)
    {
        Do sth.
    }
    else if (condition3)
    {
        Do sth.
    }
}
else if (condition4)
{
   Do sth.
}
于 2013-02-19T21:26:55.677 回答
0
BOOL someCondition;
if (condition1)
{
   if (condition2)
   {
      //Do sth.
   }
   else if (condition3)
   {
      //Do sth.
   }
   else
   {
      // get back to check condition4.
      someCondition = YES;
   }
}
if (condition4 && someCondition)
{
   //Do sth.
}
于 2013-02-19T21:27:49.880 回答