cocoa - NSBrowser / NSTreeController with async data -
i have nsbrowser needs display data comes rest api. api takes while return results, nice handle network traffic in background (lazy fetching). subtree needs refresh reflect server side changes.
i've tried 2 different approaches:
- using nsbrowserdelegate. when [browserdelegate browser:child:ofitem:] or similar function ends requesting data not yet loaded, return 0 count , kick off background processing. when data becomes available have columns reloaded (not efficient, messes user's selection new data comes in).
- using nstreecontroller. got work using blocking/synchronous approach. however, whenever update model, nsbrowser resets tree , moves selection parent. i've tried [obj mutablearrayvalueforkey] approach. i've tried [treecontroller insertobject:atarrangedobjectindexpath:] approach. i've toggled "preserve selections" flag. i've toggled "select on insert". no matter do, nsbrowser doesn't want cleanly update relevant subtree.
bottom line: best practice asynchronously loading data nsbrowser?
Comments
Post a Comment