problem while getting selected value from tableview
<p>i have 3 different arrays. 1)for ids 2)for names 3)for emailid.</p>

<p>i am displaying names in a tableview.</p>

<p>And displaying selected name with checkmark in tableview.</p>

<p>Now i need to get selected name id and email from the ids and emailid arrays.</p>

<p>And that retrieved id and emails are need to save in two different arrays. </p>

<p>for that my code is </p>

<pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.sourceArray count];;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    static NSString *CellIdentifier = @"Cell";

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

    [cell.textLabel setText:[self.sourceArray objectAtIndex:indexPath.row]];

        if ([self.selectedArray containsObject:[agentemails objectAtIndex:indexPath.row]]){
            NSLog(@"111111111111");
            [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
        }
        else
        {
            [cell setAccessoryType:UITableViewCellAccessoryNone];
        }
        if ([self.selected_agentid_email containsObject:[agentids objectAtIndex:indexPath.row]]){
            NSLog(@"222222222222");
            [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
        }
        else
        {
            [cell setAccessoryType:UITableViewCellAccessoryNone];
        }
        if(myBoolean){
            [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
        }



    return cell;
}


#pragma mark -
#pragma mark Table view delegate

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

        if ([self.selectedArray containsObject:[agentemails objectAtIndex:indexPath.row]]){
            NSLog(@"33333333333333");
            [self.selectedArray removeObjectAtIndex:[self.selectedArray indexOfObject:[agentemails objectAtIndex:indexPath.row]]];
        }
        else
        {
            [self.selectedArray addObject:[agentemails objectAtIndex:indexPath.row]];
        }
        if ([self.selected_agentid_email containsObject:[agentids objectAtIndex:indexPath.row]]){
            NSLog(@"4444444444444444");
            [self.selected_agentid_email removeObjectAtIndex:[self.selected_agentid_email indexOfObject:[agentids objectAtIndex:indexPath.row]]];
        }
        else
        {
            [self.selected_agentid_email addObject:[agentids objectAtIndex:indexPath.row]];
        }

    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
</code></pre>

<p>but the problem i am getting is,</p>

<p>eg: if i select 3 names in a tableview  i am able to retrieve only one emailid and 3 ids.</p>

<p>i did n't get what's problem is.</p>

<p>can any one please help me.</p>

<p>Thank u in advance. </p>
