I need to display an NSTableView (through a NSWindowController) by interrogation a webService
for one of the interrogation, the webServices return me more than hundred rows of data
So there are 2 problems:
1. the datasource takes a big amount of memory
2. it can takes a long time before the datasource is entirely loaded
I think the solution is to interrogate the webservice for the number of visible lines (and further to asynchronously load some other lines to prepare the scrolling).
To obtain he number of visible lines, I do:
let nbVisibleRows = Int(myTable.frame.size.height / (myTable.rowHeight+1))
At the initialization of the window, I effectively obtains the good number of rows
My problem is that the window can be resized.
So I add and observer:
NotificationCenter.default.addObserver(self, selector: #selector(windowDidResize(_:)), name: NSWindow.didEndLiveResizeNotification, object: self)
and in the méthod windowDidResize I ask for the number of visible rows exactly as I wrote above.
I do do understand the size of the table.frame returned in the windowDidResize method
when I load the window, it returns for the table a height of 277.0, wich is correct
when I resize the window even from a very small amount, it returns for the table a height of 2886.0
So I can't calculate the number of visible rows
Any idea what I did wrong?