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

  • Home
  • SEARCH
  • 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 6812163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:24:55+00:00 2026-05-26T20:24:55+00:00

I have window with 3 table views (10.7.2, Xcode 4.2). They are all created

  • 0

I have window with 3 table views (10.7.2, Xcode 4.2).
They are all created in IB and NSButtonCells are connected with outlets.

I created controller class and I filled all three views with some sample data:

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
    return 10;
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn    *)aTableColumn row:(NSInteger)rowIndex {

NSButtonCell *buttonCell;

if(aTableView == dimensionTable) {    
    [dimensionButtonCell setTitle:@"Dimension"];
    buttonCell = dimensionButtonCell;
}
else if(aTableView == shopTable) {
    [shopButtonCell setTitle:@"Shop"];
    buttonCell = shopButtonCell;
}
else if(aTableView == countryTable) {
    [countryButtonCell setTitle:@"Country"];
    buttonCell = countryButtonCell;
}


return buttonCell;

}

I have 2 questions:

  1. I cannot change checkbox state through GUI. I can change it programatically, though. It blinks a bit, when you hold down mouse button, but doesn’t allow change…

  2. I tried to fill data as with views, without outlets to cells. It didn’t work. Are NSButtonCell cels within cell views somehow different as view based Table Views or “normal” cel based Table Views?

  • 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-26T20:24:56+00:00Added an answer on May 26, 2026 at 8:24 pm

    After long struggle I manage to find the solution for the problem. One part of the problem was simple bug at the data model side, but it wasn’t crucial, something much more difficult was to be done with NSTableView delegate and datasource.

    THere were mainly 3 difficulties that prevented good understanding and managing this problem:

    • apple’s documentation lacks of any reasonable explanation about differences and typical usage of - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndexin table view’s data source and - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row of its delegate. While it may seem that you would need latter method, because NSButtonCells are custom NSCells it turns out it is not necessary, but I left it at the end anyway.

    • internal conversions in NSTableView methods

    • problem is not documented almost anywhere on the net

    Here are steps you should do:

    - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
    
        buttonCell = [aTableColumn dataCell];
    
        NSString *columnKey = [aTableColumn identifier];
    
        return buttonCell;
    
    }
    

    You can see this method has to be implemented whether you use it or not.

    - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    
        buttonCell = [tableColumn dataCell];
    
        NSString *columnKey = [tableColumn identifier];
    
        if(tableView == dimensionTable) {    
    
    //        returnObject = @"Dimension";
            //        [dimensionButtonCell setTitle:@"Dimension"];
            //        buttonCell = dimensionButtonCell;
        }
    
        else if(tableView == shopTable) {
    
            [buttonCell setState:[[mySelectedShops objectAtIndex:row] integerValue]];
            [buttonCell setTitle:[myShops objectAtIndex:row]];
    
        }
    
        else if(tableView == countryTable) {
    
            [buttonCell setState:[[mySelectedCountries objectAtIndex:row] integerValue]];
            [buttonCell setTitle:[myCountries objectAtIndex:row]];
    
        }
    
        return buttonCell;
    
    }
    

    you can see I used second method, however objectValueForTableColumn could be used solely.
    You can also see, I have NSMutableArray mySelectedShops and mySelectedCountries to hold NSInteger (1 or 0) wrapped in NSNumber for each row in Table View.

    If you set the state or integerValue of NSCell makes no difference. Both will check and uncheck NSButtonCell with values 1 or 0 of NSInteger type.

    - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
    
        NSString *columnKey = [aTableColumn identifier];
    
        if(aTableView == dimensionTable) {    
    //        [dimensionButtonCell setTitle:@"Dimension"];
    //        buttonCell = dimensionButtonCell;
        }
        else if(aTableView == shopTable) {
    
            [mySelectedShops replaceObjectAtIndex:rowIndex withObject:[NSNumber numberWithInteger:[(NSCell*)anObject integerValue]]];
    
        }
        else if(aTableView == countryTable) {
    
            [mySelectedCountries replaceObjectAtIndex:rowIndex withObject:[NSNumber numberWithInteger:[(NSCell*)anObject integerValue]]];
    
        }
    
    }
    

    Although I passed NSInteger value to NSCell object, anObject here is of __NSCFBoolean type, which means something doesn’t work as expected. To be able to replace object value to arrays I have casted it to NSCell only to get integerValues. It actually works without cast as well, so it is another mystery to me, but I like it more that way.

    It is clear Apple is moving to view based cells like in UITableView. Still, I hope this will help to somebody.

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

Sidebar

Related Questions

Hey everyone, running into a bit of an issue, I have created all my
i have this MainViewController, which is a controller for my table view. Whenever I
i have created a tableview default app with xcode. But: in AppDelegate a add
I have more than 3 views and also one window view ( pdfReader.xib nib
I have this code in my table view controller (and delegate): - (void)tableView:(UITableView *)tableView
Sup fellas, so I have a navigation controller with a table view to which
I am developing a Window-based application in which, I added tabBarController and have table
I have created a table view and want that when i click a cell
I have a set of table views which the user can switch between using
I have two views.In first view, I have a table view and I am

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.