Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is just an example.</p> <p>Follow the Steps to accomplish:</p> <ol> <li>Drag and Drop a table View.</li> <li>Drag and Drop a table Cell View (NSTableCellView) inside the Table View Cell. Now, Your table view is view based.</li> <li>Set The Identifier for table Cell View (NSTableCellView) as "CheckBoxCell" -> NSTableCellView of the first Column and the other column's table cell view as "TextBoxCell".</li> <li>Delete the image view present inside the NSTableCellView.</li> <li>Drag and Drop a Check Box(Not NSButtonCell, it should be NSButton).</li> <li>Drag and Drop array controller and place an outlet "myArrayController"</li> </ol> <blockquote> <pre><code>@interface ExAppDelegate : NSObject &lt;NSApplicationDelegate,NSTableViewDelegate&gt; @property (assign) IBOutlet NSWindow *window; @property (strong) NSMutableArray *myArray; @property (strong) IBOutlet NSTableView *myTableView; @property (strong) IBOutlet NSArrayController *myArrayController; @end </code></pre> </blockquote> <pre><code>@implementation ExAppDelegate @synthesize myArray; @synthesize myTableView; - (void)applicationWillFinishLaunching:(NSNotification *)notification { [self.myTableView setDelegate:self]; if(self.myArray == nil) { self.myArray = [NSMutableArray array]; for (NSUInteger i=0; i &lt; 10; i++) { NSMutableDictionary *test = [NSMutableDictionary dictionary]; [test setValue:[NSString stringWithFormat:@"%ld",i] forKey:@"Name"]; NSUInteger marks = i + 10; [test setValue:[NSString stringWithFormat:@"%ld",marks] forKey:@"Marks"]; [self.myArray addObject:test]; } } [self.myArrayController rearrangeObjects]; } - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSTableCellView *checkBoxCell = nil; if(tableView == self.myTableView) { //Get the Column Number NSUInteger tableCol = [tableView.tableColumns indexOfObject:tableColumn]; if(tableCol == 0) { checkBoxCell = (NSTableCellView *)[tableView makeViewWithIdentifier:@"CheckBoxCell" owner:tableColumn]; NSArray *myViews = [checkBoxCell subviews]; NSButton *checkBoxButton = [myViews objectAtIndex:0]; NSDictionary *valueDictionary = [self.myArray objectAtIndex:row]; NSString *titleValue = [valueDictionary valueForKey:@"Name"]; [checkBoxButton setTitle:titleValue]; NSUInteger mod = row % 2; if(mod == 0) { [checkBoxButton setState:NSOnState]; } else { [checkBoxButton setState:NSOffState]; } } else { checkBoxCell = (NSTableCellView *)[tableView makeViewWithIdentifier:@"TextBoxCell" owner:tableColumn]; } } return checkBoxCell; } @end </code></pre> <p>=============================================</p> <p><em>Bindings(Ignoring Data Source) myArrayController - > bind to - > ExAppDelegate - > Content Array - > model key Path -> self.myArray tableView - > bind to -> Table Content - > Content Array - > arrayController -> arranged Objects. DO NOT SET ANY MODEL KEY PATH FOR TABLE VIEW BINDINGS</em></p> <p>=============================================</p> <ol> <li>I have set a Outlet as mytableView to NSTableView</li> <li>Assuming Two Columns in a Table View</li> <li>Assuming one column should be set with a Check Box Cell and the other with a Text Field Cell</li> </ol> <p>*You want to set the Unique title to the check box cell along with marking as checked or not. (FYI : I alternatively marking checked and unchecked, Like 1st row will be checked and the second will be unchecked and so on...)</p> <ol> <li><p>I'm considering an Array Containing a Dictionary with 2 Keys -- > 1st Key (Name) 2nd Key(Marks)</p></li> <li><p>Then Later Implement the method "- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row"</p> <p>I Hope this will be help in fixing the issue. :)</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload