Day 45: trivial nsview programming in fact
I had promised to write about the different ways to do view drawing; one way to get the data to draw a view is to provide standard getters and setters for the object(s) the view should draw. This is however too trivial do write something sensible about I now see.
One tip I can mention is to mark the view dirty whenever you are setting a new object on thr vire because NSView won’t redraw otherwise. I assume you can all write getters and setters or better, synchronised properties, so I won’t spell that out.
The bssic structure of the drawing part also becomes easy once you know what you have to draw. It will be difficult to give an example since it will widely differ for each use.
Using delegates is slightly different; make sure your model is updated and somehow tell the view to reload it’s data similar to how NSTableView works. In fact NSTableViews datasource and delegate methods are a good example of how to write these. Remember to include a reference to the control in the datasource methods in case you later get multiple instances of the same class sharing a single control object.