Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force NSBrowser to reload

Tags:

macos

cocoa

I'm new to Cocoa so apologies if this doesn't make sense.

I'm using an NSBrowser to get a Finder-style column view of some data from a web service. The NSURLConnection result is returned asynchronously.

My issue is that the browser correctly calls its delegate to populate columns when the app starts, but I can't make it reload once I've got the data.

I've tried reloadDataForRowIndexes, noteHeightOfRowsWithIndexesChanged, addColumn, reloadColumn and loadColumnZero, but none of them trigger the browser to call numberOfRowsInColumn on the delegate as I would expect (and see on startup).

I know the browser delegate is ok because I can see it being called at startup.

Is there another way to ask the browser to refresh, or do I need to try another approach?

Plan B would be to fire the urlConnection off on another thread, and block the browser. I'm not keen on blocking the UI thread as I fear this will cause a beachball.

Plan C maybe would be to delay the browser loading from the nib file until the data was ready, but I'd have a similar issue next node unless I load all nodes a column early in anticipation.

like image 482
Matt Avatar asked Jan 20 '23 00:01

Matt


2 Answers

[browser reloadColumn:0] did not work for me but [browser loadColumnZero].

like image 183
Ingolf Koch Avatar answered Jan 28 '23 19:01

Ingolf Koch


[browser reloadColumn:0] is the right way to go. This just works, no workaround needed. Your error is elsewhere if this does not work for you.

like image 21
Nikolai Ruhe Avatar answered Jan 28 '23 19:01

Nikolai Ruhe