lukeredpathLuke Redpath
In my quest for loosely coupled, reusable UITableViewController design, this is my #GOOS inspired design so far. http://t.co/pSggwg47
andrewa2Andrew Sardone
@lukeredpath interested in “repository” vs MOC objects, & splitting apart datasource/delegate objs – I usually extract them into same object
lukeredpathLuke Redpath
@andrewa2 I think the controller is quite suited to being the delegate as its largely to do with dealing with user interaction.
andrewa2Andrew Sardone
@lukeredpath absolutely agree, just found the mapping from models/keypaths to index paths is usually shared between delegate & data source.
lukeredpathLuke Redpath
@andrewa2 my "data source" object encapsulates that, but provides a public objectForIndexPath: method, like my LRTableModel API does.
andrewa2Andrew Sardone
@lukeredpath gothca. I usually have the same method privately, but it should be exposed publicly for delegate use. I like it – thanks!
andrewa2Andrew Sardone
@lukeredpath It feels quite right! The repository just gives your VC (and hence data source) what it wants, no hard CD dependency.
lukeredpathLuke Redpath
@andrewa2 results from back from API, Core Data context is updated, result set picks up change automatically, controller updates - easy!
andrewa2Andrew Sardone
@lukeredpath yep! That’s *exactly* how my model works, but VC coordinates an NSFRC & a DataController (query remote API, update CD) – gross!
andrewa2Andrew Sardone
@lukeredpath same. A lot of my VCs had a warmUpEngine method, tells DataController to query remote API. The repository removes those details
lukeredpathLuke Redpath
@andrewa2 I've hit one hitch - if you use Storyboards and rely on prototype cells, its hard to test the controller without the storyboard.
lukeredpathLuke Redpath
@andrewa2 the work I did the other day on LRFetchResultSet was key to getting "repository" objects working in a loosely coupled way.