title: Switch statements and instance variable allocation in Objective-C
body: <p>I seem to be having a problem creating new local variables inside a switch statement.  I thought it was something in my class headers, but was even getting errors trying to allocate a new NSObject.  Here's my syntax:</p>
  
  <pre><code>-(NSArray *)charactersFromChapter:(NSInteger)number {
      NSObject *noError = [[NSObject alloc] init];
      //line above does not cause error
      NSArray *characters;
      switch (number) {
          case 1:
              NSObject *obj = [[NSObject alloc] init];
              //error happens in line above (Expected expression)
              characters = [NSArray arrayWithObject:obj];
              break;
          case 2:
  
              break;
          case 3:
  
              break;
      }
      return characters;
  }
  </code></pre>