Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with multiple navigationcontrollers in a tabbarcontroller that points to one detail view
    primarykey
    data
    text
    <p>I have an app that have one tabbarcontroller that contains a navigationcontroller for each tab. Every navigationcontroller ends up at a view controller with the name DetailViewController. But if the user navigates to DetailViewController on one tab and then switches tab and navigates to DetailViewController there too, and the app crashes with the error: </p> <pre><code>2011-08-19 21:14:45.257 Kluringar[4368:ef03] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 0]' </code></pre> <p>The code that pushes DetailViewController looks like this:</p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { kluringIdString = [[kluringar objectAtIndex:indexPath.row] objectForKey:@"id"]; DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"]; [self.navigationController pushViewController:detail animated:YES]; } </code></pre> <p>The code that gets the data from the database and adds it to the array looks like this:</p> <pre><code>-(void) getAllRowsFromTableNamed { //—-retrieve rows—- NSString *qsql = [NSString stringWithFormat:@"SELECT * FROM Kluringar ORDER BY rubrik"]; sqlite3_stmt *statement; kluringar = [[NSMutableArray alloc] init]; NSMutableDictionary *kluringarDictionary = [[NSMutableDictionary alloc] init]; if (sqlite3_prepare_v2( db, [qsql UTF8String], -1, &amp;statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { char *kluringId = (char *) sqlite3_column_text(statement, 2); NSString *kluringIdStr = [[NSString alloc] initWithUTF8String: kluringId]; char *rubrik = (char *) sqlite3_column_text(statement, 3); NSString *rubrikStr = [[NSString alloc] initWithUTF8String: rubrik]; //---add items--- [kluringarDictionary setValue:kluringIdStr forKey:@"id"]; [kluringarDictionary setValue:rubrikStr forKey:@"rubrik"]; [kluringar addObject:[kluringarDictionary copy]]; } //—-deletes the compiled statement from memory—- sqlite3_finalize(statement); } } </code></pre> <p>Here is a link to the storyboard: <a href="http://alanihre.se/storyboard.png" rel="nofollow">storyboard</a></p> <p>Thans in advance! :)</p>
    singulars
    1. This table or related slice is empty.
    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