objective-c switch case with multiple arguments objective-c switch case with multiple arguments ios ios

objective-c switch case with multiple arguments


You can use multiple cases right below each other.

switch (myInteger) {    case 1:    case 3:    case 5:        // statements        break;    case 2:        // statements        break;    default:        // statements        break;}


case 1:case 3:case 5:    statements;    break;case 2:    statements;    break;default:    break;


For Swift 3 there is a modification that I would like to mention

switch some value to consider {case 1: //single argument  print("ABC")case 2,3: // multiple arguments  print("KLM")default:  print("XYZ")}

Hope it helps you. Thanks


matomo