title: iPhone - didSelectRowAtIndexPath - selecting row 26 or greater mystery
body: <p>My UITableView has up to 50 rows in each section, populated by a plist dictionary which contains arrays (sections) which contains arrays (row objects) which contains two strings (row title / filename and file extension).</p>
  
  <p>Select row 1 - 25 (item 0-24) and everything behaves normally. But select a row greater than 26 (item 25) and the app crashes. I'm a novice at all this and I tried researching for the answer but I'm at a loss for how to research this. Can tables only have 25 rows per section?</p>
  
  <p>Any ideas? Thank you!</p>
  
  <p>Jon</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView
  didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
      NSUInteger section = [indexPath section];
      NSUInteger row = [indexPath row];
      NSMutableString *key = [categories objectAtIndex:section];
      NSMutableArray *sound = [categoriesSounds objectForKey:key];
      NSMutableString *soundName = [[sound objectAtIndex: row] objectAtIndex: 0];
      NSMutableString *soundOfType = [[sound objectAtIndex: row] objectAtIndex: 1];
  
  
      if (leftSwitch.on == YES) {
          showLeft.text = soundName;
          left    = [[NSBundle mainBundle] pathForResource:(@"%@", soundName) ofType:(@"%@", soundOfType)];
          AudioServicesCreateSystemSoundID((CFURLRef)[NSURL
                                                      fileURLWithPath:left], &amp;soundNegZ); 
          AudioServicesPlaySystemSound (soundNegZ); 
  
          if (indexPath != leftOldIndexPath) {
              UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
              newCell.accessoryType = UITableViewCellAccessoryCheckmark;
              UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:leftOldIndexPath];
              oldCell.accessoryType = UITableViewCellAccessoryNone;
              leftOldIndexPath = indexPath;
          }
          [tableView deselectRowAtIndexPath:indexPath animated:YES];
  
  
      }
  
      if (downSwitch.on == YES) {
          showDown.text = soundName;
          down    = [[NSBundle mainBundle] pathForResource:(@"%@", soundName) ofType:(@"%@", soundOfType)];
          AudioServicesCreateSystemSoundID((CFURLRef)[NSURL
                                                      fileURLWithPath:down], &amp;soundNegX); 
          AudioServicesPlaySystemSound (soundNegX);
  
          if (indexPath != downOldIndexPath) {
              UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
              newCell.accessoryType = UITableViewCellAccessoryCheckmark;
              UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:downOldIndexPath];
              oldCell.accessoryType = UITableViewCellAccessoryNone;
              downOldIndexPath = indexPath;
          }
          [tableView deselectRowAtIndexPath:indexPath animated:YES];
      }
  
      if (rightSwitch.on == YES) {
          showRight.text = soundName;
          right    = [[NSBundle mainBundle] pathForResource:(@"%@", soundName) ofType:(@"%@", soundOfType)];
          AudioServicesCreateSystemSoundID((CFURLRef)[NSURL
                                                      fileURLWithPath:right], &amp;soundPosX);    
          AudioServicesPlaySystemSound (soundPosX);
  
          if (indexPath != rightOldIndexPath) {
              UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
              newCell.accessoryType = UITableViewCellAccessoryCheckmark;
              UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:rightOldIndexPath];
              oldCell.accessoryType = UITableViewCellAccessoryNone;
              rightOldIndexPath = indexPath;
          }
          [tableView deselectRowAtIndexPath:indexPath animated:YES];
  
      }
  
  
  
  }
  </code></pre>
  
  <hr>
  
  <p>For "EXC_BAD_ACCESS" in the console, this is the debugger output (error trace is marked with asterisks):</p>
  
  <pre><code>0x91a6cec0  &lt;+0000&gt;  mov    0x8(%esp),%ecx
  0x91a6cec4  &lt;+0004&gt;  mov    0x4(%esp),%eax
  0x91a6cec8  &lt;+0008&gt;  cmp    $0xfffeb010,%ecx
  0x91a6cece  &lt;+0014&gt;  je     0x91a6cf35 &lt;objc_msgSend+117&gt;
  0x91a6ced0  &lt;+0016&gt;  test   %eax,%eax
  0x91a6ced2  &lt;+0018&gt;  je     0x91a6cf1a &lt;objc_msgSend+90&gt;
  0x91a6ced4  &lt;+0020&gt;  mov    (%eax),%edx
  0x91a6ced6  &lt;+0022&gt;  push   %edi
  **0x91a6ced7  &lt;+0023&gt;  mov    0x20(%edx),%edi** 
  0x91a6ceda  &lt;+0026&gt;  push   %esi
  0x91a6cedb  &lt;+0027&gt;  mov    (%edi),%esi
  0x91a6cedd  &lt;+0029&gt;  mov    %ecx,%edx
  0x91a6cedf  &lt;+0031&gt;  shr    $0x2,%edx
  0x91a6cee2  &lt;+0034&gt;  and    %esi,%edx
  0x91a6cee4  &lt;+0036&gt;  mov    0x8(%edi,%edx,4),%eax
  0x91a6cee8  &lt;+0040&gt;  test   %eax,%eax
  0x91a6ceea  &lt;+0042&gt;  je     0x91a6cef5 &lt;objc_msgSend+53&gt;
  0x91a6ceec  &lt;+0044&gt;  cmp    (%eax),%ecx
  0x91a6ceee  &lt;+0046&gt;  je     0x91a6cf00 &lt;objc_msgSend+64&gt;
  0x91a6cef0  &lt;+0048&gt;  add    $0x1,%edx
  0x91a6cef3  &lt;+0051&gt;  jmp    0x91a6cee2 &lt;objc_msgSend+34&gt;
  0x91a6cef5  &lt;+0053&gt;  pop    %esi
  0x91a6cef6  &lt;+0054&gt;  pop    %edi
  0x91a6cef7  &lt;+0055&gt;  mov    0x4(%esp),%eax
  0x91a6cefb  &lt;+0059&gt;  mov    (%eax),%eax
  0x91a6cefd  &lt;+0061&gt;  jmp    0x91a6cf09 &lt;objc_msgSend+73&gt;
  0x91a6ceff  &lt;+0063&gt;  nop    
  0x91a6cf00  &lt;+0064&gt;  mov    0x8(%eax),%eax
  0x91a6cf03  &lt;+0067&gt;  pop    %esi
  0x91a6cf04  &lt;+0068&gt;  pop    %edi
  0x91a6cf05  &lt;+0069&gt;  xor    %edx,%edx
  0x91a6cf07  &lt;+0071&gt;  jmp    *%eax
  0x91a6cf09  &lt;+0073&gt;  sub    $0x4,%esp
  0x91a6cf0c  &lt;+0076&gt;  push   %ecx
  0x91a6cf0d  &lt;+0077&gt;  push   %eax
  0x91a6cf0e  &lt;+0078&gt;  call   0x91a6d33f &lt;_class_lookupMethodAndLoadCache&gt;
  0x91a6cf13  &lt;+0083&gt;  add    $0xc,%esp
  0x91a6cf16  &lt;+0086&gt;  xor    %edx,%edx
  0x91a6cf18  &lt;+0088&gt;  jmp    *%eax
  0x91a6cf1a  &lt;+0090&gt;  call   0x91a6cf1f &lt;objc_msgSend+95&gt;
  0x91a6cf1f  &lt;+0095&gt;  pop    %edx
  0x91a6cf20  &lt;+0096&gt;  mov    0xe79d961(%edx),%eax
  0x91a6cf26  &lt;+0102&gt;  test   %eax,%eax
  0x91a6cf28  &lt;+0104&gt;  je     0x91a6cf30 &lt;objc_msgSend+112&gt;
  0x91a6cf2a  &lt;+0106&gt;  mov    %eax,0x4(%esp)
  0x91a6cf2e  &lt;+0110&gt;  jmp    0x91a6ced4 &lt;objc_msgSend+20&gt;
  0x91a6cf30  &lt;+0112&gt;  mov    $0x0,%edx
  0x91a6cf35  &lt;+0117&gt;  ret    
  0x91a6cf36  &lt;+0118&gt;  nopw   %cs:0x0(%eax,%eax,1)
  </code></pre>
  
  <p>My cellForRowAtIndexPath method:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView
           cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      NSUInteger section = [indexPath section];
      NSUInteger row = [indexPath row];
      NSString *key = [categories objectAtIndex:section];
      NSArray *nameSection = [categoriesSounds objectForKey:key];
      static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
                               SectionsTableIdentifier];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc]
                   initWithStyle:UITableViewCellStyleDefault
                   reuseIdentifier:SectionsTableIdentifier] autorelease];
      }
      cell.textLabel.text = [[nameSection objectAtIndex:row] objectAtIndex: 0];
  
      if (leftSwitch.on == YES){
          NSUInteger leftRow = [leftOldIndexPath row];
          NSUInteger leftSection = [leftOldIndexPath section];
          cell.accessoryType = (row == leftRow &amp;&amp; section == leftSection &amp;&amp; leftOldIndexPath !=nil) ?
          UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
          }
      if (downSwitch.on == YES){
          NSUInteger downRow = [downOldIndexPath row];
          NSUInteger downSection = [downOldIndexPath section];
          cell.accessoryType = (row == downRow &amp;&amp; section == downSection &amp;&amp; downOldIndexPath !=nil) ?
          UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
      }
      if (rightSwitch.on == YES){
          NSUInteger rightRow = [rightOldIndexPath row];
          NSUInteger rightSection = [rightOldIndexPath section];
          cell.accessoryType = (row == rightRow &amp;&amp; section == rightSection &amp;&amp; rightOldIndexPath !=nil) ?
          UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
      }
  
      return cell;
  }
  </code></pre>