iPhoneアプリケーションにUITableViewを実装しました。さらに、UITableViewに複数の行の選択を追加しましたが、問題は、特定の行を選択してからテーブルをスクロールし、選択されていない(マークされていない)それぞれの行に戻ると、didSelectRowAtIndexPathメソッドが表示されることです。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath
{
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        if([tableView cellForRowAtIndexPath:indexPath].accessoryType==UITableViewCellAccessoryNone)
        {  
            [tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;        
            [selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
            NSLog(@"Select now %d",[selectedIndexes count]);
        }
        else if([tableView cellForRowAtIndexPath:indexPath].accessoryType==UITableViewCellAccessoryCheckmark)
        {
            [tableView cellForRowAtIndexPath:in dexPath].accessoryType=UITableViewCellAccessoryNone;
            [selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
            NSLog(@"DeSelect now %d",[selectedIndexes count]);
        }   
}
解決策を教えてください。