Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting “EXC_BAD_ACCESS” when accessing instance variable from within UITableView delegate method
    text
    copied!<p>My iPhone application blows up when it accesses an instance variable from within one of the UITableView delegate methods. I think I'm retaining it so I do not understand why I can't access it without a problem.</p> <p>Here's my .h file</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "AlertSummaryCell.h" #import "AlertDetailViewController.h" @interface AlertSummaryTableViewController : UITableViewController { NSDictionary *alerts; NSString *alertKind; } </code></pre> <p>@property (nonatomic, retain) NSDictionary *alerts; @property (nonatomic, retain) NSString *alertKind;</p> <p>@end</p> <p>In my .m, the application dies at the first NSLog call:</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"AlertSummaryTableViewController.numberOfRowsInSection entered"); NSLog(@" alerts description = %@", [alerts description]); // To know how many alert summaries we have, get the value for count out of the input dictionary int theCount = [[alerts objectForKey:@"count"] intValue]; NSLog(@" Going to return %d",theCount); return theCount; } </code></pre> <p>What am I missing???</p> <p>There's no problem at all in the viewDidLoad method:</p> <pre><code> - (void)viewDidLoad { NSLog(@"AlertSummaryTableViewController.viewDidLoad entered"); NSLog(@" alerts description = %@", [alerts description]); // We want the View title to include the alert count // To know how many alert summaries we have, get the value for count out of the input dictionary int theCount = [[alerts objectForKey:@"count"] intValue]; // Now construct the title text and set our views title to it NSString *myTitle = [[NSString alloc] initWithFormat:@"%@ Alerts (%d)",alertKind,theCount]; [self setTitle: myTitle]; // Memory cleanup [myTitle release]; [super viewDidLoad]; } </code></pre>
 

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