FAQ Database Discussion Community


Suggestions need for UI : Listing NSMutableArray elements

objective-c,nsmutablearray,nstableview,nsarraycontroller
I am new to Mac app development. So, I am doing some exercises in Objective-C. I have a nsmutablearray which contains list of names. I want to display a name list using MVC approach and I want perform some action while pressing name in the list view. I came across...

How to get NSTableView to use a custom cell view mixed with preset cell views?

osx,swift,cocoa,nstableview,nstableviewcell
I have a NSTableView configured in Interface Builder which uses several default cell views. However the first column's cell view needs to be created from a custom class. How do I implement NSTableViewDataSource method tableView.viewForTableColumn() so that it creates the default cell views for the remaining columns? Here's my method...

Setting NSTableView cell text

osx,swift,nstableview
I have a NSTableView that I want to populate with 20 cells, each of them will say "Test". I'm fluent with UITableView's but not so much with NSTableViews, so I went hunting online to figure this out. Oh, how confused that made me! I understand that I need to use...

Multiple NSTableCellView in one NSTableviewColumn Cocoa OSX

objective-c,osx,cocoa,nstableview
I am trying to create a NSTableview with different cells in one column. I am setting two NSTableCellView's in one column like so: And setting the data code like so: - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { // Get a new ViewCell // Since this is a single-column table...

NSTableView sort bindings - programatic Solution

objective-c,osx,cocoa,nstableview,nsarraycontroller
First-time questioner here on the site. I have been attempting to learn more about NSTableView bindings with relation to an NSArrayController by taking the bindings out of the storyboard and trying to reproduce the effect in code. I am able to configure the initial sort order of the NSTableView and...

Custom NSView in NSTableView not showing all subviews

osx,swift,interface-builder,nstableview,nsview
I'm trying to create a custom NSView to display in a column in a view-based NSTableView. The view contains 2 subviews, an NSTextField and an NSButton. I want the button to stay the width set by the constraints, and the textfield to resize when the NSView is resized. Below is...

os x user interface lectures and tutorials

xcode,osx,nstableview,nsview
Can you give me links to mac os x user interface lectures , video tutorials , tutorials ?Video format will be the best but text is fit too. That will teach about NSTableView NSView and similar interface things. It should tell how to write code using Xcode for all of...

Cocoa How to enforce specific editing behaviour to a particular row in a view based NSTableView?

objective-c,cocoa,nstableview
I have a simple view based NSTableView with one column which is populated with Core Data entities, and the row's view contains just a NSTextField. I need ONLY the first row to be non editable, and to be displayed in red. I tried to to this somewhere in applicationDidFinishLaunching :...

Edit data in the model according to the user's input in view-based NSTableView

osx,cocoa,cell,edit,nstableview
I have a view-based NSTableView where all the cells are editable. I need to refresh the data from the model every time the user modifies a textField from the view. All the doc I find is related to the cell-based NSTableView. Does anyone have a clue about this? EDIT: I'm...

NSTableView with NSCheckBox cells - how to intercept row selection?

objective-c,osx,cocoa,swift,nstableview
I have a NSTableView with cells that contain NSCheckBox. I'd like to change the behaviour of it so that any row in the table can be clicked and the checkbox in that row toggles on/off accordingly. I figured it can be done with func tableView(tableView: NSTableView, shouldSelectRow row: Int) ->...

Applying NSCheckBox state in NSTableView

osx,cocoa,swift,nstableview
I have a NSTableView that has two rows, one with checkboxes, one with textfields, and I want to apply the checkbox states from a dictionary in NSTableViewDataSource.viewForTableColumn ... // MARK: - NSTableViewDataSource func tableView(tableView:NSTableView, viewForTableColumn tableColumn:NSTableColumn?, row:Int) -> NSView? { var cellView:NSTableCellView = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! NSTableCellView; if (tableColumn!.identifier...

How can I change the double-click action for only a single column of NSTableview

cocoa,nstableview
Okay, so I have two projects that have NSTableViews. One has a single column with dates (in a , and my implementation for letting users change the dates is by changing the NSTableview's doubleAction to display an NSPopover with a graphical date picker, like so: override func viewDidLoad() { super.viewDidLoad()...

How ro change NSTableHeaderView's backgrouncolor without hiding column's titles?

xcode,osx,swift,nstableview
I have view-based NSTableView on my Swift OS X app using storyboards, which have 12 columns. I subclassed my headerview and tried to different things to change backgroundcolor, but all of them hide my titles also. This is one of many examples what tried to do: override func drawRect(dirtyRect: NSRect)...

How to invert text colour of selected NSTableView row

xcode,cocoa,nstableview
I have an NSTableView in which I'm changing the colour of the text in a particular column, but when a row is selected, the text does not change to a more appropriate colour so that it's readable. Finder's Date Modified, Size, and Kind columns have grey text, and when you...

NSTableView with dynamic height

osx,cocoa,nstableview
I am working on Xcode 6.1.1 on OSX 10.10.2 How do I make my table adjust its height, so that the height of table would always be equal to the sum of heights of all the rows. In other words, it should not display any empty rows. And adding and...

Multiple NSTableViews on one View Controller

swift,nstableview
I want to have multiple NSTableViews on one ViewController. I have implemented the first TableView with the following code: class MainViewController: NSViewController { @IBOutlet weak var tableView: NSTableView! override func viewDidLoad() { super.viewDidLoad() let nib = NSNib(nibNamed: "MyCellView", bundle: NSBundle.mainBundle()) tableView.registerNib(nib!, forIdentifier: "MyCellView") let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate appDelegate.view...

cocoa tooltip delay per object?

objective-c,osx,cocoa,nstableview
According to this article, you can change the tooltip display for your applications by modifying the NSInitialToolTipDelay user default. So far, this seems to be the only way I have found to modify how long it takes to display a tooltip, however it seems to be application wide. Does anyone...

NSTableView - how to get automatic and manual sorting working together?

osx,swift,cocoa,sorting,nstableview
I have a NSTableView in MyViewController and have an array controller bound to it. I want to be able to sort it by clicking the table column headers and it should also auto-sort. So for auto-sort I set the Sort Descriptors binding of my array controller in IB as following:...

Set NSTableCellView and subviews to have dynamic width programmatically

objective-c,osx,swift,nstableview
I have an NSTableView with cells that contain various NSTextFields and NSProgressIndicators. I set the cells up programmatically and I control their behavior programmatically. The way I have implemented my cells basically prevents me from being able to use Interface Builder. Everything works great except when I resize the NSWindow,...

What is the point of using NSTableCellView when creating view-based tables?

objective-c,xcode,cocoa,nstableview
When you create a view-based table view in Xcode's interface builder, it automatically adds an NSTableCellView control, inside of which is an NSTextField control. You better add constraints to your text field control, otherwise it won't resize properly when you resize a column. But it turns out that NSTableCellView controls...

Getting NSTableView row index of focussed row?

osx,swift,cocoa,nstableview
How can I obtain the index of the row in a NSTableView that is currently being focussed? When left-clicked the row is selected but I need the index when the row is right-clicked on, i.e. the row might not be selected when the user opens a context menu upon it...

How to keep the selected row state after collapsing the NSOutlineView Group

xcode,swift,cocoa,nstableview,nsoutlineview
I want to implement a side bar working like Finder.app. But I have no idea how to make it keeping the row selected state after collapsing and expanding the group. Any idea or suggestion will be appreciated. ...

Could not cast value of type 'NSTableCellView' to 'NSTableViewTest'

swift,nstableview
I'm trying to set up a custom class for an NSTableView and seem to be almost there with it. When I run this code I get an error message : Could not cast value of type 'NSTableCellView' (0x7fff7a859af0) to 'NSTableViewTest.MyCellView' (0x10001e480) in the line "let cell = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self)...

removeobjectAtIndex: causes index to be -1;

xcode,osx,cocoa,nsmutablearray,nstableview
I have a NSTableView that is populated by an array called tableArray. I have a button that is supposed to remove the selected item from the array. In my removeItem: method: [tableArray removeObjectAtIndex:[tableView selectedRow]; [tableView reloadData]; But I get the error: 2015-05-13 18:16:45.283 FileShedb1.0[979:303] *** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond...

Layout still needs update after calling NSTableRowView layout

osx,swift,cocoa,autolayout,nstableview
I have two NSTableView's in my app and the user can drag and drop items from table A to table B. When dragging an item to table B Xcode gives me the following layout warning message: Layout still needs update after calling -[NSTableRowView layout]. NSTableRowView or one of its superclasses...

NSTableView not sending “selected row” action when row selected with arrow keys

objective-c,cocoa,nstableview
This is a very simple issue that I know I've encountered before, but for the life of me, I can neither remember the solution nor find a page describing it: I have an NSTableView bound to a content array. When I click on rows with the cursor, the table sends...

Binding an NSTableView to an array of strings in Swift

osx,swift,cocoa,nstableview,cocoa-bindings
I'm showing the contents of an array of strings with an NSTableView via binding through an Array Controller. I have "NSString" in Class Name in the attributes inspector for the Array Controller and in the Model Key Path of the Array Controller's binding inspector I have the path to my...

Programmatically sorting NSTableView

osx,cocoa,swift,sorting,nstableview
I know how to make a tableview user-click sortable but how to sort it programmatically (without using an NSArrayController)? The docs are skimpy on this. Here is what I got: private func updateThemeTableView() { _tableViewDataDict = getAssociatedThemesFor(_type); _tableView.reloadData(); let sort = NSSortDescriptor(key: "Theme", ascending: true, selector: "caseInsensitiveCompare:"); _tableView.sortDescriptors = [sort];...

SelectedRow of NSOutlineView always returns -1

cocoa,interface-builder,nstableview,selecteditem,nsoutlineview
I have a View-based NSOutlineView, and have in the class a selection change event: - (void)outlineViewSelectionDidChange:(NSNotification *)notification { NSLog(@"Selected Row inside:%ld",[self selectedRow]); } This is the way I create my NSOutlineView: ovc = [[OutlineViewController alloc] init]; [myOutlineView setDelegate:(id<NSOutlineViewDelegate>)ovc]; [myOutlineView setDataSource:(id<NSOutlineViewDataSource>)ovc]; MyOutlineView is created in IB. Every time I click on...

View based NSTableView editing

cocoa,nstableview
I'm not sure what I'm doing wrong. Since I couldn't find any other questions (or even documentation) about this, it seems do be normally working without problems for other people. I'm simply trying to get a view based NSTableView to do support editing of it's content. I.e. the app displays...

How to get custom table cell views into NSTableView?

osx,swift,cocoa,nstableview,nstableviewcell
I have a NSTableView that uses mostly standard NSTextTableCellViews but I want some other cells that contain another UI component in my table in one or two rows. The question is: Where do I define those custom cells so that Cocoa finds them? I just dropped a custom NSTableCellView into...

NSTableView textfield cell should not go into edit on click

osx,swift,cocoa,nstableview,nstextfield
I have two NSTableViews in my app and both are set up the same, same parameters, etc., they have several columns with NSTextField cells and the first column is editable. The first table behaves like I want it: if the user clicks, the row is selected. If the user clicks...

Cocoa osx NSTableview change row highlight color

osx,cocoa,colors,nstableview,highlight
In my application I have a view based NSTableView with one column. The highlight color of the rows is set to regular (blue). I need to change that color to my custom color. In the interface builder I tried changing it but the only options are "None, regular and source...

Getting notified when an encapsulating NSTableView cell is selected?

osx,cocoa,nstableview
When a stock NSTableView's row/cell is selected, its background becomes blue and any standard NSTextfields text color becomes white. Is there a public API that lets you to get a message when an encapsulating row view or cell view is selected? Basically, I want to make a custom view that...

Disabling the NSTableView row focus ring

osx,swift,cocoa,nstableview
How do you disable the focus ring around an NSTableView row when the user right-clicks on it? I can't get it to disappear. Setting focus ring of an individual NSTableViewCell in the table to None has no effect. ...

Setting dataSource for NSTableView across scenes in a storyboard

cocoa,nstableview,osx-yosemite,nsstoryboard
I am using XCode 6 on OS X 10.10 and have a storyboard containing a window with a split view controller, as shown in the following image. The split view controller (highlighted in the image) is an instance of MyViewController, which has the following code: MyViewController.h #import <Cocoa/Cocoa.h> @interface MyViewController...

On Mac, Drag file to my NSTableVIew?

osx,swift,drag-and-drop,nstableview
I would like be able to drag (any) file to my view-based NSTableView, so in the delegate I have this setup: class MyViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource, NSDraggingDestination { @IBOutlet var tableView: NSTableView! // connected in storyboard. override func viewDidLoad() { super.viewDidLoad() tableView.registerForDraggedTypes([NSFilenamesPboardType]) // … } func draggingEntered(sender: NSDraggingInfo) -> NSDragOperation...