Uzyskiwanie „EXC_BAD_ACCESS” podczas uzyskiwania dostępu do zmiennej instancji z poziomu metody delegata UITableView
Moja aplikacja iPhone wysadza, gdy uzyskuje dostęp do zmiennej instancji z jednej z metod delegowania UITableView. Myślę, że zachowuję to, więc nie rozumiem, dlaczego nie mam do nich dostępu bez problemu.
Oto mój plik .h
#import <Foundation/Foundation.h>
#import "AlertSummaryCell.h"
#import "AlertDetailViewController.h"
@interface AlertSummaryTableViewController : UITableViewController {
NSDictionary *alerts;
NSString *alertKind;
}
@ atrybuty (nonatomic, retain) NSDictionary *; @ właściwość (nieatomowa, zachowaj) NSString * alertKind;
@koniec
W moim pliku .m aplikacja umiera podczas pierwszego połączenia NSLog:
- (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;
}
Czego mi brakuje???
W metodzie viewDidLoad nie ma żadnego problemu:
- (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];
}