I am fairly new to OS X Cocoa programming but have decided to give it a go with the new Swift language.
I have an NSTableView
with 1500
I recently found myself in a very similar situation, having a cell based NSOutlineView
that was blazing fast pre-Yosemite and almost crawled to a halt after upgrading to Yosemite.
In my experience, enabling layer-backing on the table view itself is not enough, you also have to enable it for the NSScrollView
that contains your table view and it's NSClipView
.
After making those changes my table view was up to speed again but experiencing some strange visual artifacts. Those might or might not be relevant in your situation since you're not using an source list NSOutlineView
that uses the new vibrancy/transparency stuff in Yosemite.
In any case, those "effects" went away as soon as I converted to a view based table.
You need to simply turn off the "Draws Background" on the text cell (or the group cell)
I've got a similar problem. I'm also new to Swift and Apple development in general. My project was working well until I started adding a 1000 or more rows.
After some playing around, I've narrowed the issue down to the way that my dictionary based data source is being accessed. This might point you in the right direction.
func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? {...
return myDictionary.values.array[row] //-- this makes access very slow, jerky with pauses
return myDictionary[someKey] //-- this makes access a lot faster, smooth and slick
Looks like my data source needs some re-work. It still hasn't been tested with large quantities of data, but at the outset seems to make a significant difference.
According to Apple, OSX never enable QuartzCore by default (as iOS, instead, do). So, you need to:
Quoting Apple docs:
In iOS apps, Core Animation is always enabled and every view is backed by a layer. In OS X, apps must explicitly enable Core Animation support by doing the following:
Link against the QuartzCore framework. (iOS apps must link against this framework only if they use Core Animation interfaces explicitly.) Enable layer support for one or more of your NSView objects by doing one of the following:
In your nib files, use the View Effects inspector to enable layer support for your views. The inspector displays checkboxes for the selected view and its subviews. It is recommended that you enable layer support in the content view of your window whenever possible. For views you create programmatically, call the view’s setWantsLayer: method and pass a value of YES to indicate that the view should use layers. Enabling layer support in one of the preceding ways creates a layer-backed view. With a layer-backed view, the system takes responsibility for creating the underlying layer object and for keeping that layer updated. In OS X, it is also possible to create a layer-hosting view, whereby your app actually creates and manages the underlying layer object. (You cannot create layer-hosting views in iOS.) For more information on how to create a layer-hosting view, see “Layer Hosting Lets You Change the Layer Object in OS X.”
More on: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/SettingUpLayerObjects/SettingUpLayerObjects.html
Recently they have introduced the concept called "Reuse queues", where in only the rows which are currently visible are actually there in the table. The rows which go out of the clip, while scrolling are replaced by the newly introduced rows. This was introduced for performance enhancements. But considering million x 7 views, I suppose there might be a lot of CPU cycles wasted in reuse queue.
Also cells are light weight as compared to views.
If possible you can consider, restructuring the single tableview to multiple tableviews. Practically human being needs to view the data with atleast some simple predicate in their mind. For example, in an organization you might want to view
instead of viewing all employee details at a time.
Thus initializing a table view, only with the required information would enhance both, the performance and UX.