當它從一個UITableView委託方法中訪問實例變量時,我的iPhone應用程序爆炸。我想我會保留它,所以我不明白爲什麼我不能在沒有問題的情況下訪問它。從UITableView委託方法中訪問實例變量時獲取「EXC_BAD_ACCESS」
這是我的.h文件
#import <Foundation/Foundation.h>
#import "AlertSummaryCell.h"
#import "AlertDetailViewController.h"
@interface AlertSummaryTableViewController : UITableViewController {
NSDictionary *alerts;
NSString *alertKind;
}
@屬性(非原子,保留)的NSDictionary *警報; @property(nonatomic,retain)NSString * alertKind;
@end
在我的.m,應用死在第一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;
}
我在想什麼???
有沒有問題,在viewDidLoad方法都:
- (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];
}
謝謝你的提示!!!!! – Dale 2009-09-20 13:42:25