UITableView didSelectRowAtIndexPath , different value from what is displayed in section rows!

StackOverflow https://stackoverflow.com/questions/5933541

سؤال

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row];
    _XMLDetailsView.aDirectory = aDirectory;

if (indexPath.section == 0) // First section
{
    _XMLDetailsView.aDirectory = aDirectory;
}
else if(indexPath.section == 1) // Second Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count]];
    _XMLDetailsView.aDirectory = aDirectory;

}
else if(indexPath.section == 2) // Third Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count] +3];
    _XMLDetailsView.aDirectory = aDirectory;

}
else if(indexPath.section == 3) // Fourth Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count] +9];
    _XMLDetailsView.aDirectory = aDirectory;

}

}

is this the correct way to select certain row of value from certain section? because when i didSelectRowAtIndexpath for e.g section "C" , it is suppose to display the value that starts from array (4) . but instead at section "C" , it displays the value from array(0) again. i'm stuck for so long on this , anyone with any suggestion or help?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top