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 6997043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:14:02+00:00 2026-05-27T20:14:02+00:00

I have a table of items with a checkmark disclosure button, and I want

  • 0

I have a table of items with a checkmark disclosure button, and I want to create a second table based off which of those are checked. I know I’m supposed to use the method tableView:accessoryButtonTappedForRowWithIndexPath, but I have no clue how to implement it.

So let’s say this is my code, where do I enter the ButtonTapped method and how is it implemented?

@implementation RootViewController

@synthesize detailViewController;


#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [self createFlowerData];
    [super viewDidLoad];
}

/*
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
*/
/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
*/

// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}


#pragma mark -
#pragma mark Size for popover
// The size the view should be when presented in a popover.
- (CGSize)contentSizeForViewInPopoverView {
    return CGSizeMake(320.0, 600.0);
}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return [flowerSections count];
}


- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [[flowerData objectAtIndex:section] count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"CellIdentifier";

    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }

    // Configure the cell.
    [[cell textLabel] setText:[[[flowerData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"name"]];
    [[cell imageView] setImage:[UIImage imageNamed:[[[flowerData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"picture"]]];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [flowerSections objectAtIndex:section];
}


- (void)createFlowerData {

    NSMutableArray *redFlowers;
    NSMutableArray *blueFlowers;

    flowerSections=[[NSMutableArray alloc] initWithObjects:
                    @"Red Flowers",@"Blue Flowers",nil];

    redFlowers=[[NSMutableArray alloc] init];
    blueFlowers=[[NSMutableArray alloc] init];

    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Poppy",@"name",
                           @"poppy.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Poppy",@"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Tulip",@"name",
                           @"tulip.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Tulip",@"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Gerbera",@"name",
                           @"gerbera.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Gerbera",@"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Peony",@"name",
                           @"peony.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Peony",@"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Rose",@"name",
                           @"rose.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Rose",@"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Hollyhock",@"name",
                           @"hollyhock.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Hollyhock",
                           @"url",nil]];
    [redFlowers addObject:[[NSMutableDictionary alloc]
                           initWithObjectsAndKeys:@"Straw Flower",@"name",
                           @"strawflower.png",@"picture",
                           @"http://en.wikipedia.org/wiki/Strawflower",
                           @"url",nil]];

    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Hyacinth",@"name",
                            @"hyacinth.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Hyacinth_(flower)",
                            @"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Hydrangea",@"name",
                            @"hydrangea.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Hydrangea",
                            @"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Sea Holly",@"name",
                            @"seaholly.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Sea_holly",
                            @"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Grape Hyacinth",@"name",
                            @"grapehyacinth.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Grape_hyacinth",
                            @"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Phlox",@"name",
                            @"phlox.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Phlox",@"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Pin Cushion Flower",@"name",
                            @"pincushionflower.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Scabious",
                            @"url",nil]];
    [blueFlowers addObject:[[NSMutableDictionary alloc]
                            initWithObjectsAndKeys:@"Iris",@"name",
                            @"iris.png",@"picture",
                            @"http://en.wikipedia.org/wiki/Iris_(plant)",
                            @"url",nil]];

    flowerData=[[NSMutableArray alloc] initWithObjects:
                redFlowers,blueFlowers,nil];

    [redFlowers release];
    [blueFlowers release]; 
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath  {
    return 75.0;
}


#pragma mark -
#pragma mark Table view delegate

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

    /*
     When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
     */
    detailViewController.detailItem = 
         [[flowerData objectAtIndex:indexPath.section] 
          objectAtIndex: indexPath.row];

}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [flowerData release];
    [flowerSections release];
    [detailViewController release];
    [super dealloc];
}

Ultimately I want it something like in this image, where the items checked off on the right appear as a new table on the left:

enter image description here

  • 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-27T20:14:02+00:00Added an answer on May 27, 2026 at 8:14 pm

    I haven’t tried but this should get you well on your way to solve your problem:

    1. Create a NSMutableArray to hold your selected rows: selectedRowsArray
    2. Implement tableview:didSelectRowAtIndexPath: delegate method:
    3. Inside this method, get a reference to the selected cell with UITableViewCell *cell = [self.tableview cellForRowAtIndexPath:indexPath].
    4. Check if the cell already has a checkmark in it, if NO, add the checkmark and add the object you are interested in to the mutable array…

    Ex:

    if (cell.accessoryType != UITableViewCellAccessoryCheckmark)
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        [selectedRowsArray addObject:THE_OBJECT];
    } else {
        cell.accessoryType = UITableViewCellAccessoryNone;
        [selectedRowsArray removeObject:THE_OBJECT];
    }
    

    Now you can use the mutable array to populate the other tableview with data. Remember to call reloadData on the tableview every time you add or remove an object from the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Table which has SWT.CHECK style so I can remove checked items. I
I need to search in a table for items which have all of my
I have a table of items and which supplier they came from: tabel items
I have a table with items in it (id, name, etc) and I want
I have a table (items) which is in the following format: ITEMNO | WEEKNO
Hey guys, I have an table in which the user can tap on items
I have a table ITEMS, which has the props id, site_id, frequency So far
I have a table Items which stores fetched book data from Amazon. This Amazon
I have a table Items which should have a corresponding record in the table
I have a table displaying items. Each cell has a button that is used

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.