I have a permanent crash with my UITableView when I set the number of rows in a table to zero. It crashes with error EXC_BAD_ACCESS. The failure is internal to the UITableView, so I cannot directly understand what went wrong, although this should be a stupid mistake on my part.
The stack trace is as follows:
#0 0x0194ca60 in objc_msgSend ()
And my code is as follows:
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { m_oPositionTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 367) style:UITableViewStylePlain]; m_oPositionTableView.delegate = self; m_oPositionTableView.dataSource = self; m_oPositionTableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self addSubview:m_oPositionTableView]; m_oAppDelegate = (AyersGTSAppDelegate *)[[UIApplication sharedApplication] delegate]; } return self; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
A failure occurs only when the number of rows in the table is 0. If I rigidly set the number of rows returned to 1, the alarm does not appear.
source share