-2

Sorry to ask this (I rarely use switch statements) but I am getting an error with this but it seems valid to me (but obviously isn't):

  NSInteger section=indexPath.section;

  switch(section){
    case 0:
      Item *mi = self.miArray[indexPath.row]; // <- expected expression
      ...
      return cell;
      break;
    case 1:
      Item *mi = self.miArray[indexPath.row];
      break;
  }

What am I doing wrong?

timpone
  • 19,235
  • 36
  • 121
  • 211
  • possible duplicate of [Weird Switch error in Obj-C](http://stackoverflow.com/questions/1180550/weird-switch-error-in-obj-c) – GoodSp33d Nov 26 '14 at 10:38

2 Answers2

1

You can either put the case in braces (case 0: { Item *mi ... }) or add a ; after the case statement (case 0:;).

Either of that should help but I actually forgot why this is necessary.

Found an explanation here: Weird Switch error in Obj-C

Community
  • 1
  • 1
Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
0

Declaration is not allowed within switch. Declare Item before entering to switch and do the initialization within the switch.

user3946110
  • 122
  • 1
  • 9