Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 903729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:56:02+00:00 2026-05-15T15:56:02+00:00

I have a navigation controller with a table view. In most tutorials I’ve read

  • 0

I have a navigation controller with a table view. In most tutorials I’ve read they usually have an array of view controllers (or subclasses of) stored locally in the table view controller that they use to push onto the navigation stack when a table cell is selected.

In my current project I have a lot of data that is loaded from an XML file. This data is kept central in a singleton class. This is my ‘model’ if you will.

So in my tableview controller I don’t have an array of view controllers (I didn’t want to have redundant data stored in my view controller when it’s already stored elsewhere). Instead I access the data from the singleton and create a view controller, initialize it with the appropriate data and then push that onto the navigation stack every time a table cell is selected.

This is a sample of the tableview:didselectrowatindexpath: method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    DetailViewController *nextController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];

    // Here I setup some data from the singleton (just an example)
    nextController.title = [mySingleton.titles objectAtIndex:[indexPath row]];

    [self.navigationController pushViewController:nextController animated:YES]; 

    [nextController release];
}

So my question is does this approach have the potential to suffer performance loss? I’m worried about allocating and releasing memory every time the user selects a table cell. On the other hand, since I will potentially have a lot of data, I don’t want to have to repeat this data by storing it in an array of controllers.

I could always just have my singleton prepare the view controllers and store those instead of just the raw data. But I find it a bit weird that the model is always implicit in the controller. Is there a proper way of having the model stored independently of controller knowledge?

How would you approach this situation?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:56:02+00:00Added an answer on May 15, 2026 at 3:56 pm

    Your approach is right.
    In this line of code:

    nextController.title = [mySingleton.titles objectAtIndex:[indexPath row]];
    

    you are not “allocating and releasing” any data but the pointer’s data. nextController.title will point to some element inside mySingleton.titles. The data lives only inside your singleton’s class as long as you don’t call any copy method on the arrays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a navigation controller which also has a table view. I want to
I have created a table view with navigation controller. I want to link table
I have an application with navigation controller and some table view controller. In table
Sup fellas, so I have a navigation controller with a table view to which
I have table view navigation controller and the data is loaded from url. I
I have a navigation controller with a root view controller (UITableViewController). This table view
I have a table view which is inside a navigation controller, however besides this
In my IB I have a navigation controller which has in it a view
Say I have NavigationController->Root[Table View Controller subclass] So from didSelectRowAtIndexPath of my Table View
I have a view controller (derived from UIViewController not UITableViewController) containing a table view.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.