Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3873924
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:05:35+00:00 2026-05-19T22:05:35+00:00

i have 3 different arrays. 1)for ids 2)for names 3)for emailid. i am displaying

  • 0

i have 3 different arrays. 1)for ids 2)for names 3)for emailid.

i am displaying names in a tableview.

And displaying selected name with checkmark in tableview.

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

And that retrieved id and emails are need to save in two different arrays.

for that my code is

- (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];
}

but the problem i am getting is,

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

i did n’t get what’s problem is.

can any one please help me.

Thank u in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:05:36+00:00Added an answer on May 19, 2026 at 10:05 pm

    This may not be the solution you were looking for but I would recommend creating a class to store those values so you only have to work with an array of all values and an array of selected values. This will greatly decrease the complexity of working with several arrays. I have not actually tested the following code but this will be sort of what it would like.

    //Agent.h
    @interface Agent : NSObject
    {
        NSString    *_name;
        NSString    *_aID;
        NSString    *_email;
    }
    
    @property(retain)   NSString    *name;
    @property(retain)   NSString    *aID;
    @property(retain)   NSString    *email;
    
    @end
    
    //Agent.m
    @implementation Agent
    
    @synthesize name = _name;
    @synthesize aID = _aID;
    @synthesize email = _email;
    
    - (void) dealloc
    {
        [_name release];
        [_aID release];
        [_email release];
    
        [super dealloc];
    }
    
    @end
    
    //Your selection code will then look like this
    -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        Agent *agent = (Agent*)[self.allAgents objectAtIndex:indexPath.row];
    
        if (UITableViewCellAccessoryCheckmark == cell.accessoryType) {
            [self.selectedAgents removeObject:agent];
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
        else {
            [self.selectedAgents addObject:agent];
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
        }
    
        //All 3 values are guaranteed to be there
        NSLog(@"Agent: %@ %@ %@", agent.name, agent.aID, agent.email);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 20 different variable-length arrays, each holding a unique value, and I need
I have an array with different IDs going from 1 to 4000. I need
I have two different arrays. One array, a, for a list of people. My
If I have two different arrays and all I can do is check whether
How can I store arrays in single array? e.g. I have four different arrays,
I have two arrays containing the same elements, but in different orders, and I
I have two arrays, and I am using array_diff_assoc() to get the difference, but
I have two html select objects named with the same name (they are arrays
I Have an array of different ids, I want to iterate this array and
I have displayed a row of items with same div class name but different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.