Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView index beyond bounds error
    primarykey
    data
    text
    <p>I am experiencing an error at the following line:</p> <pre><code>cell1.textLabel.text = [settings objectAtIndex:indexPath.row]; </code></pre> <p>And this is the uncaught inception error i receive:</p> <blockquote> <pre><code>Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]' First throw call stack: (0x2265012 ... 0x21a5 0x1) libc++abi.dylib: terminate called throwing an exception (lldb) </code></pre> </blockquote> <p>Here's my code:</p> <p><strong>.h:</strong></p> <pre><code>@interface ViewController : UIViewController &lt;UITableViewDataSource ,UITableViewDelegate&gt;{ //Settings Table IBOutlet UITableView *settingTable; NSMutableArray *settings; } @property (nonatomic, retain) UITableView *settingTable; @property (nonatomic, retain) NSMutableArray *settings; </code></pre> <p><strong>.m:</strong></p> <pre><code>@synthesize settingTable; @synthesize settings; - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (!settings) { return 0; } if ([settings count] &gt; 0){ return [settings count]; } else return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (settingTable) { NSLog(@"%@", settings); UITableViewCell *cell1 = [settingTable dequeueReusableCellWithIdentifier:@"MainCell1"]; if (cell1 == nil) { cell1 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainCell1"]; } cell1.textLabel.text = [settings objectAtIndex:indexPath.row]; return cell1; } // ... - (void)viewDidLoad { [super viewDidLoad]; settingTable.delegate = self; settingTable.dataSource = self; //settings table settings = [[NSMutableArray alloc] initWithObjects:@"Downloads", @"Queue", @"FAQ", nil]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } </code></pre>
    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.
 

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