0

What would be more efficient to load content on a detail view from a view controller with a table view?

Should I pass the variables over to the detail view from the didSelectRowAtIndexPath: method or is it better to make a JSON call to the server and load the data into a dictionary on the detail view?

I notice some lag when I pass the data from the view controller to the detail view via the didSelectRowAtIndexPath: method

thanks for any help

IronManGill
  • 7,222
  • 2
  • 31
  • 52
user2588945
  • 1,681
  • 6
  • 25
  • 38

4 Answers4

0

It's not totally clear from your question where the data is coming from. I'm assuming because you mention a JSON call that when you select an item on your table view you need to make a web service call to fetch additional information about that item before displaying your detail view.

If that's the case then you should make the web service call and load the data whilst in the detail view controller. Apple's interface guidelines recommend you do it this way to give the appearance of responsiveness. The detail view controller will be displayed immediately after the row in the table view has been tapped. You can use an activity indicator or loading graphic in your detail view to let the user know additional information is being downloaded.

This is a considerably better experience than waiting for the data to download and only then triggering your view transition.

lxt
  • 31,146
  • 5
  • 78
  • 83
  • So, I should just pass the record id to the detail view and then make a call to the web service for all the data? At the moment I'm passing data from the table view to the detail view in the didSelectRow method detailViewController.titleStr = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"title"]; – user2588945 Aug 05 '13 at 09:52
  • Yes, pass the record ID to the detail view controller, and have the detail view controller handle pulling in the additional info from your service. – lxt Aug 05 '13 at 11:39
0

Use didSelectRowAtIndexPath: method to send id or any unique variable to detailedViewController... and in detailedViewController using this unique variable or id to get data from json in viewDidLoad: or viewWillAppear: this is easy and best way to post data in detailedViewController

iosLearner
  • 1,312
  • 1
  • 16
  • 30
0

If you already have complete data in table view controller itself then you can pass an object instead of passing too many variables. Simply create a domain class , declare variables and objects, set properties and synthesize. Now pass this domain class object to your controller. But in case you have some data in table view and again you need to make a server call to fetch more details, you can pass only id and make a server call on Detail View only.

IOS Dev
  • 286
  • 2
  • 14
0
DetailView = [[DetailViewController]alloc]init];
 DetailView.strValue = sValue.
[self.navigationController pushViewController:DetailView animated:Yes];

DetailView is the object of the you detail view. import this class then make its instance like above and strValue is the string taken in detail view and sValue is string in current view controller has some value in it passing to other view.

check this link also.

Community
  • 1
  • 1
iPhone Programmatically
  • 1,211
  • 2
  • 22
  • 54
  • thanks! that's what I'm doing at the moment. So, it's fine to pass the data from one vc to the other and no need to download and parse it again on the detail view? – user2588945 Aug 05 '13 at 10:35