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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:21:15+00:00 2026-05-28T08:21:15+00:00

The tableview is populated from a .plist. I want to be create an ADD

  • 0

The tableview is populated from a .plist.
I want to be create an “ADD” button on the navBar if one or more cells are checked and remove the “ADD” button once all of the cells are unchecked. The best I’ve been able to do is add the button when a cell is checked and remove the button when the cell is unchecked but this is not taking into account that other cells may have a checkmark in them. If any cell is in the table has a checkmark, the “ADD” button should be present.
The example code I’m working with can be found here: http://developer.apple.com/library/ios/#samplecode/TouchCells/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008062

In the didSelectRowAtIndexPath method, I’ve added:

if (targetCustomCell.checked)
{

UIBarButtonItem *saveButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add" 
style:UIBarButtonItemStyleDone target:self action:@selector(add)];

self.navigationItem.rightBarButtonItem = saveButtonItem;
}
else
{
    self.navigationItem.rightBarButtonItem = nil;
}

I’m including the DidSelectRowAtIndexPath for reference:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// find the cell being touched and update its checked/unchecked image
CustomCell *targetCustomCell = (CustomCell *)[tableView cellForRowAtIndexPath:indexPath];
[targetCustomCell checkAction:nil];

// don't keep the table selection
[tableView deselectRowAtIndexPath:indexPath animated:YES];

// update our data source array with the new checked state
NSMutableDictionary *selectedItem = [self.dataArray objectAtIndex:indexPath.row];
[selectedItem setObject:[NSNumber numberWithBool:targetCustomCell.checked] forKey:@"checked"];
}

Thank you for any help – it’s really appreciated!

  • 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-28T08:21:15+00:00Added an answer on May 28, 2026 at 8:21 am

    I guess this is what you want.

    // first check the check box value
    // if selected then add object
    if (checkbox.selected) {
     [self.dataArray addObject: <get your object using button tag match with row no>];
    }
    
    // if deselected then remove that object
    else {
     [self.dataArray removeObject: <get your object using button tag match with row no>];
    }
    
    
    // check the array count
    // if > 0 then add bar button
    if ([self.dataArray count] > 0) {
     UIBarButtonItem *saveButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add" 
    style:UIBarButtonItemStyleDone target:self action:@selector(add)];
    
    self.navigationItem.rightBarButtonItem = saveButtonItem;
    }
    
    // if = 0 then remove bar button
    else {
    self.navigationItem.rightBarButtonItem = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Sectioned Tableview sourced from a pList which I want to drill
Xcode 4.2 iPhone Project I am trying to create a tableView that's populated from
I have a UITableViewController managing a grouped tableView. The tableView is populated from a
I have a uitableview that is populated from a sqlite query. I want to
I have a grouped tableview that is populated with XML data in one section.
I have a tableview where each cell is populated with dynamic data from an
I'm adding to a project a TableView populated with countries to choose from. Added
I have a UITableView that is populated with custom cells (inherited from UITableViewCell ),
I'm currently trying to populate an UITableView from a plist downloaded from the internet.
I currently add data to a NSMutableArray and then read back from it to

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.