I am trying to send an NSDictionary to a TableViewController, the data originally comes from a .plist file. I just want to send an object that exists further down the hierarchy to a new TableViewController. But problems arise when I try to count the number of elements in numberOfSectionsInTableView.
- (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]; } }
If I just use allKeys as follows:
NSLog([[dict objectForKey:@"Room"] allKeys]);
It returns ("Position 1", "Item 2") in the console.
But when I add the "count" method as follows:
NSLog(@"%@", [[[dict objectForKey:@"Room"] allKeys] count]);
I just get: Program signal: "EXC_BAD_ACCESS".
What am I missing here?
source share