CellForRowAtIndexPath not called for all partitions

I have a UITableView in which there are five sections. Just as the name describes cellForRowAtIndexPath, only called for the first four. All connections were made with respect to the data source and delegate. In addition, my number ofOfSectionsInTableView explicitly returns 5. A listing of the number of sections from cellForRowAtIndexPath shows the correct number, which confirms that cellForRowAtIndexPath is simply not called for all sections. What's happening? I answered this question rather hard, but could not find it. If you have already answered this, please forgive me and point me in the right direction.

My cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    switch (indexPath.section) {
        case 0:
            cell.textLabel.text = ticket.description;
            break;
        case 1:
            cell.textLabel.text = ticket.ticketStatus;
            break;
        case 2:
            cell.textLabel.text = ticket.priority;
            break;
        case 3:
            cell.textLabel.text = ticket.customerOfficePhone;
            break;
        case 4: {
            //This never ever gets executed
            Comment *comment = [ticket.comments objectAtIndex:indexPath.row];
            cell.textLabel.text = comment.commentContent;
            break;
        }
    }

    return cell;
}

My NumberOfSectionsInTableView:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 5;
}

My NumberOfRowsInSection:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSInteger numberOfRows;

    if (section == 4) {
        numberOfRows = [ticket.comments count];
    }
    else {
        numberOfRows = 1;
    }

    return numberOfRows;
}

Any suggestions are welcome. Thanks in advance.

+5
2

-! . , , . , , , , , , , cellForRowAtIndexPath , . , , .

+4

. .

EDIT:

[ticket.comments count]; , , ?.   if cellForRowAtIndexPath: ticket.comments if section == 4, .

if(indexPath.section == 4){

NSLog(@"Ticket Array:%@",ticket.comments);

}

:

ticket.comments ? , "Comment" - ? comment object, 4.

case 4:
         {
            Comment *comment = (Comment *)[ticket.comments objectAtIndex:indexPath.row];
            cell.textLabel.text = comment.commentContent;
            break;
         }

, .

0

All Articles