getData()はこのメソッドの最後に一度だけ呼び出されるため、おそらく私のコードは次のメソッドでクラッシュします。
さらに、didSelectRowAtIndexPathコードは次のとおりです。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath
{
[tableView deselectRowAtIndexPath:newIndexPath animated:YES];
// Set
[[GlobalObject obj] setData:[(CustomCell*)[tableView cellForRowAtIndexPath:newIndexPath] getData]];
}
キャッチされなかった例外'NSInvalidArgumentException'が原因でアプリを終了しています。理由:'-[CustomCell getData]:認識されないセレクターがインスタンスに送信されました。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section == 0)
{
...
return cell;
}
else
{
// Create a button table view cell
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
if (cell == nil)
{
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CustomCell"] autorelease];
}
[cell setButton:[ ...];
return cell;
}
}
上に示したように、セルは自動解放され、おそらくこれがアプリがクラッシュした理由です。セルは自動解放プールに移動し、getDataが認識されないセレクターに送信されました。どうすれば問題を解決できますか?