私はカスタム UITableViewCell (ReservationsCell.h/ReservationsCell.m/ReservationsCell.xib) を持っており、その中にボタンがあります。NIB ファイルでは、識別子は として設定されreservationsCell
、ファイルの所有者は View Controller として設定され、カスタム クラスは として設定されReservationsCell
ます。ボタンの TouchUpInside イベントは、ViewController ファイルに記述された IBAction にリンクされています。
問題
ボタンをクリックすると、EXC_BAD_ACCESS が返されます-[NSObject performSelector:withObject:withObject:]: message sent to deallocated instance 0x398e7ff0
試み
ここ数時間で NSZombies を試すように教えられましたが、エラーの原因は私のtableView:cellForRowAtIndexPath
方法であることがわかりました。
コード
ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
.....
// register ReservationCell nib
[self.reservationsTableView registerNib:[UINib nibWithNibName:@"ReservationsCell" bundle:nil] forCellReuseIdentifier:@"reservationsCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"reservationsCell";
ReservationsCell *cell = (ReservationsCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = [nib objectAtIndex:0];
}
......
}
Zombies によると、エラーをスローする特定の行はdequeueReusableCellWithIdentifier
.
私を助けてください。前もって感謝します!:)