Note that there are some explanatory texts on larger screens.

plurals
  1. POCounting allKeys from NSDictionary returns EXC_BAD_ACCESS
    text
    copied!<p>I am trying to send an NSDictionary to a TableViewController, the data originally comes from a .plist file. I simply want to send an object that exists further down the hierarchy to new TableViewController. But problems occur when I try to count the number of items in numberOfSectionsInTableView.</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Gets the dictionary for the currently selected row NSDictionary *dict = [[data objectForKey:[[data allKeys] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]; // Checks if the key "Room" exists if([dict objectForKey:@"Room"]) { SalesFairSessionTableViewController *sessionViewController = [[SalesFairSessionTableViewController alloc] init]; // Sets the data in the subview Controller [sessionViewController setData:[dict objectForKey:@"Room"]]; // And the title [sessionViewController setTitle:[dict objectForKey:@"Title"]]; // Problem is here... returns EXC_BAD_ACCESS NSLog(@"%@", [[[dict objectForKey:@"Room"] allKeys] count]); [self.navigationController pushViewController:sessionViewController animated:YES]; [sessionViewController release]; } } </code></pre> <p>If I just use allKeys like this:</p> <pre><code>NSLog([[dict objectForKey:@"Room"] allKeys]); </code></pre> <p>It returns ("Item 1", "Item 2") in the console.</p> <p>But when I add the ”count” method like this:</p> <pre><code>NSLog(@"%@", [[[dict objectForKey:@"Room"] allKeys] count]); </code></pre> <p>I just get: Program received signal: “EXC_BAD_ACCESS”.</p> <p>What am I missing here?</p>
 

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