Quote:
Originally Posted by coondog
I think I see what you mean...
Would you mind giving me an example? - I don't need any code. Perhaps, just a model/controller flow for an app you've done. If it's not too much to ask.
Chris.
|
Yeah, so I can describe something I did in general terms.
So we had a bunch of items on a server that users could view and edit and add to and then we would sync those items back to the server.
So the items are model objects. But those models don't need to know about all the issues with transport over the net (codes as JSON in our case) and nor did they need to know how to deal with failures (phone network disconnects, server is slow, server is down, etc.)
And the models themselves didn't need to deal with the issues of merging updates and changes.
So on both the phone side and the server side, we had these model objects. Which were managed by a controller that exposed what looked like a simple array of those objects. That controller hides all the complexity behind that. That controller also takes care of dumping objects from memory when we're tight for memory, and reconstituting those objects when they are needed again and so on. It hands out proxies to objects when they aren't immediately available so the user interface is always smooth.
Internally the controller knows what to do with inserts and updates and merges and that sort of thing. And that controller uses another controller that deals with the specifics of managing the network and queuing network operations that can't happen at the moment for various reasons, etc.
And then our view controllers just need access to an array of stuff (and be notified when that stuff changes). They don't care about any of those details. They don't care if the objects they are getting are real or proxies. They don't care if those objects are coming from local cache or the network itself.
So we have a single instance of an "array" controller that behaves like a simple mutable array. A pointer to that instance is stored in the app delegate. In turn, that controller uses another controller to send and retrieve actual objects from the server.
There's a little more to it than that, because the controllers have helper objects for certain things. But I hope that at least gives you a high level real world case.