I have a CustomersViewController with a table view of customers. Click on a customer (didSelectRowAtIndexPath) and a OrdersViewController shows a table view of orders for that customer. I have test data in a NSArray to test with for now. However, at some point I’ll need to do a call to a web service to get the order data. In which controller is it proper to make the call to the web service? In the didSelectRowAtIndexPath of the CustomersViewController or the viewWillAppear of the OrdersViewController? Any best practices and advice is much appreciated. Thanks.
I have a CustomersViewController with a table view of customers. Click on a customer
Share
Think about the nouns, not the verbs. A table view controller like you are describing displays a list of objects of a certain type. It should care most about that type. If you want info about another type of object, than another controller should handle that.
So
CustomersViewControllersounds like it handles everything about customers, andOrdersViewControllersounds like it handles everything about orders.So the OrdersViewController should handle fetching orders