ツヨシのブログ

技術的な事とか日常の事とか徒然なるままに

スポンサーリンク

TableViewを使っていると「dequeueReusableCellWithIdentifier」で「Thread 1:signal SIGABRT」となって困った

スポンサーリンク

エラー事項

TableViewを使った時に、以下の部分で「Thread 1:signal SIGABRT」となって実行できない。

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{staticNSString*CellIdentifier =@"Cell";UITableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifierforIndexPath:indexPath];
    cell.textLabel.text=cellList[indexPath.row];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;returncell;
}

エラースクリーンショット

エラーのスクリーンショットはこんな感じ。

f:id:ginga0118:20131230190403p:plain

例外キャッチ

「Thread 1:signal SIGABRT」は厄介だなーと思いつつ、main.mに例外処理を埋め込み詳細を探ってみる。

    @autoreleasepool {
        @try {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
        @catch (NSException *exception) {
            NSLog(@"%@",exception);
        }

    }

次の例外をキャッチした。この内容によりググってみると。

2013-12-30 18:52:48.738 iDutch[1929:70b] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:5261

どうやらセルに対する、Identifierの指定がなかったようだ。ガックシ。。。つまり以下のようにIdentifierを追加した。

f:id:ginga0118:20131230190407p:plain

まとめ

  • 「Thread 1:signal SIGABRT」がでても焦らず、例外キャッチで見極める。
  • プロパティの設定不足が多い気がする。
  • グーグル先生は偉大である。

参考

http://stackoverflow.com/questions/20217796/data-retrieving-from-a-view-to-uitableviewcell-in-storyboard