Note that there are some explanatory texts on larger screens.

plurals
  1. POError with detailTextLabel from NSArray in UITableView
    primarykey
    data
    text
    <p>I'm creating a Table View with the Detail Right style of cells (prototype cells). In implementing the self.detailLabelText.text on an array I have I'm receiving an error message when I attempt to load the table. Below is the code:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"SimpleTableItem"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:simpleTableIdentifier]; } switch (pickerSelection) { case 0: cell.textLabel.text = [visitList1 objectAtIndex:indexPath.row]; cell.detailTextLabel.text = [windows1 objectAtIndex:indexPath.row]; break; case 1: cell.textLabel.text = [visitList2 objectAtIndex:indexPath.row]; cell.detailTextLabel.text = [windows2 objectAtIndex:indexPath.row]; break; } return cell; } </code></pre> <p>I'm receiving the error message: </p> <blockquote> <p>Terminating app due to uncaught exception 'NSRangeException', reason: '<em>*</em> -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]'</p> </blockquote> <p>The table loads correctly with the main textLabel, and I can load a string after <code>cell.detailTextLabel =</code> so I know that my setup is correct. I also can NSLog both of the arrays I'm trying to load, just not in the detailLabelText. </p> <p>I know the error message has to due with the expected length of an array, I just can't figure out what or where. Sorry for an elementary question. I'm a noob.</p> <p>UPDATE: Here is my numberOfRowsInSelection method:</p> <pre><code> - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { switch (pickerSelection) { case 0: return [visitList1 count]; return [windows1 count]; break; case 1: return [visitList2 count]; return [windows2 count]; break; } return 10; } </code></pre> <p>Each of the arrays have over 3 items. i threw that last "return 10;" in there just in case something wasn't working right with the switch statement, but it doesn't seem to matter. </p> <p>Update 2: When I replace my windows1 array with static strings they populate in the detail area of the table. That's great (although I now seem to have some sort of problem with my original window arrays). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload