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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:13:40+00:00 2026-06-06T13:13:40+00:00

I have an NSDictionary that holds all the data: One title (not important for

  • 0

I have an NSDictionary that holds all the data:

  • One title (not important for this question)
  • One link (not important for this question)
  • One array of NSDictionary containing again 1 title and 1 link

I’m displaying this data in a view based table view like this:

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tv
{
    if (tv == _downloadTable) 
    //I use this "if" because I have another tableView that has nothing to do
    //with this one
    {
        return [[myDictionary objectForKey:@"myArray"] count];
    }
}

I want 2 columns in this tableView, one to display the title and one with a checkbox, that would do something letting me know which row is checked.

- (NSView *)tableView:(NSTableView *)tv viewForTableColumn :(NSTableColumn *)tableColumn row :(NSInteger)row 
{
    if (tv == _downloadTable) 
    {
        if (tableColumn == _downloadTableTitleColumn) 
        {
            if ([[[myDictionary         objectForKey:@"myArray"]objectAtIndex:row]objectForKey:@"title"]) 
            {
            NSString *title = [[[myDictionary objectForKey:@"myArray"]objectAtIndex:row]objectForKey:@"title"];
            NSTableCellView *result = [tv makeViewWithIdentifier:tableColumn.identifier owner:self];
            result.textField.stringValue = title;
            return result;
            }
        }
       if (tableColumn == _downloadTableCheckColumn) 
       {
           NSLog(@"CheckBox"); //I wanted to see exactly when that was called
                               //But it didn't help me :(
           NSButton *button = [[NSButton alloc]init];
           [button setButtonType:NSSwitchButton];
           [button setTitle:@""];
           return button;
       }
   }
}

Right now when I run it and click on the checkbox it does nothing
(of course because I don’t know how to make it do something.
Where should I put the code that should do something?

The main goal is an editable list of downloads, right now the list is displayed, with the checkbox right next to the title at each lines.
I would like to know which checkBox are checked and which are not.

I tried this:

[button setAction:@selector(checkBoxAction:)];

- (void)checkBoxAction: (id)sender
{
   NSLog(@"I am button : %@ and my state is %ld", sender, (long)[sender state]);
}

But I can’t figure out how to get the row of that button, to know which title is associated with this checkBox.

I also tried the setObjectValue method of the tableView without success.

The way I would like it to work is:

I have a “start downloading” button that check if each checkbox is checked or not and launch the next action (downloading) only with the checked row.

I would like to avoid bindings because I plan to make it work on iOS too and I don’t want to have different code for iOS.

  • 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-06-06T13:13:42+00:00Added an answer on June 6, 2026 at 1:13 pm

    You could try using the button’ tag property setting it for each button you place as the number (location) in the tableview. Look here!!!

    Detecting which UIButton was pressed in a UITableView

    [EDIT1]

    If people actually decided to read the linked post you would realize that the answer is actually there.

    Try adding:

    [button setTag:row];
    [button addTarget:self action:@selector(checkBoxAction:) forControlEvents:UIControlEventTouchUpInside];
    

    inside the else of your viewForTableColumn routine:

    In your checkBoxAction routine:

    - (void)checkBoxAction: (id)sender{
       NSLog(@"I am button : %@ and my state is %@", sender.tag, [sender state]);
    }
    

    I also think that once you begin digging further into your code, you are going to want to start using the auto-dequeuing capability of the TableViewCell objects. I believe that you are going to find yourself in a memory alloc/dealloc problem.

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

Sidebar

Related Questions

the question explains it all. For instance, if I have a NSDictionary like this
I have an NSDictionary. It holds several objects, including an array of child NSDictionaries,
I have this NSDictionary that I want to load into a table view. It
I have an NSDictionary that logs this: address = 30 East 23rd Street; address1
I have a NSDictionary that contains data converted from json data, like {message_id:21} .
i have an NSDictionary that contain in value and i need to get this
I have an NSDictionary that we will say is like this: key: value: name
I have a NSDictionary that I get from a webservice. Each object in this
I have a simple NSDictionary that I am trying to populate with data from
I have an NSDictionary containing other NSDictionaries that I save to a plist. Its

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.