0
 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   {

    static NSString *cellId = @"Cell";
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    CurrentCell *cell = (CurrentCell *)[self.tableView dequeueReusableCellWithIdentifier:cellId];


    if (cell == nil)
    {
        NSLog(@"cell == nil");
        cell = [[CurrentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }


    NSLog(@"the cell is %@", cell);
    Current *current = [currents objectAtIndex:indexPath.section];

    [cell setCellWithCurrent:current];


    return cell;

}

ストーリーボードに再利用識別子を追加し、デリゲートとデータソースを設定しましたが、それでもこのエラーが発生しました:

    *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:],          /SourceCache/UIKit/UIKit-2372/UITableView.m:5471
2013-11-04 23:47:34.206 MyApp[7417:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(0x394452a3 0x3333497f 0x3944515d 0x342082af 0x32773f79 0x325c50a1 0x325c5055 0x325c255d 0x325a730b 0x325be7c7 0x3257a803 0x35e4ed63 0x35e4e901 0x35e4f835 0x35e4f21b 0x35e4f029 0x325808eb 0x3941a6cd 0x394189c1 0x39418d17 0x3938bebd 0x3938bd49 0x377592eb 0x325cb2f9 0xec869 0x36bf7b20)
libc++abi.dylib: terminate called throwing an exception
(lldb)

テーブルでビューを表示する方法:

    else if ([segue.identifier isEqualToString:@"showCurrents"]) {

    MainViewController *mainViewController = (MainViewController*)segue.destinationViewController;

}

CurrentCell.m:

    #import "CurrentCell.h"


@interface CurrentCell ()

@end

@implementation CurrentCell
{
    UIColor *badgeColor;
    NSString *badgeText;
}

@synthesize topTitleLabel;
@synthesize descriptionLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void) setCellWithCurrent:(Current*) current
{
    NSString *title = [current title];
    [self.topTitleLabel setText:title];
    [self.descriptionLabel setText:[current description]];


}

@end

PS: このエラーはすぐには発生しませんが、しばらくリストをすばやくスクロールした後です。

4

2 に答える 2