Where should I put the code that loads data using NSURLRequest?
I'm developing my first iPhone app that downlaods some JSON data and presents it in a series of UITableView. I have a fundamental question about the place in the code where I should put the NSURLRequest.
Most of the samples I've studied, including the LazyTableImages provided by A开发者_StackOverflow社区pple, starts the request in the App Delegate and uses itself as the delegate for the connectionDidLoad.
My application uses a TabBar as a RootController, having 5 different tabs, each using a different UINavigationController based class to present the data in a series of UITableViewControllers.
My question is, considering my app structure, where should I put the code to load the data, in the AppDelegate or in the corresponding UINavigationController?
I wouldn't put it in the view controller since this is your data access code. The app delegate makes more sense. Or you could also write your own class (that takes care of download and data transformation details) and user defined delegate that app delegate implements, to be able to easily reuse it in other apps.
精彩评论