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

  • Home
  • SEARCH
  • 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 914785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:46:31+00:00 2026-05-15T17:46:31+00:00

I am trying to have a tableview that leads to another tableview whose list

  • 0

I am trying to have a tableview that leads to another tableview whose list items depend on the first view. I have the database set up properly and my problem is that when I select one item on the first page and go to the second view for the first time it works fine but when I return to the first page and go back to the second view again the list still has the old values loaded with new ones. Is there a way to destroy the array and recreate it every time the second view is loaded? Where would I do this?

Here is where my array is initialized in the delegate:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

 [self copyDatabaseIfNeeded];

 organArray = [[NSMutableArray alloc] init]; 
 procedureArray = [[NSMutableArray alloc] init];

 [Organ getInitialDataToDisplay:[self getDBPath]];

    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];

    return YES;
}

Here is where the data is added to the array in my custom class:

    + (void) getDatabase:(NSString *)dbPath WithOrganID:(NSNumber *)organID
{

 RadiologyAppAppDelegate *appDelegate = (RadiologyAppAppDelegate *)[[UIApplication sharedApplication] delegate];

 if(sqlite3_open([dbPath UTF8String],&database) == SQLITE_OK){

  const char *sql = "select * from Organ";
  sqlite3_stmt *selectstmt;

  if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK){

   while (sqlite3_step(selectstmt) == SQLITE_ROW) {

    NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);

    Procedure *procedureObj = [[Procedure alloc] initWithPrimaryKey:primaryKey];
    procedureObj.procedureName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,1)];
    procedureObj.procedureID = sqlite3_column_int(selectstmt,0);

    [appDelegate.procedureArray addObject: procedureObj];

    [procedureObj release];
   }
  }
 }
 else
  sqlite3_close(database);
}

Finally, here is my view controller:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

 Procedure *procedureObj = [appDelegate.procedureArray objectAtIndex:indexPath.row];
 PVCprocedureObj = appDelegate.procedureArray;

 cell.textLabel.text = procedureObj.procedureName;

 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;

}

Thanks for the help!

  • 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-15T17:46:32+00:00Added an answer on May 15, 2026 at 5:46 pm

    I would pass the data-object (data to be shown in the second table) to the 2nd controller. I think this is the easiest approach and you are not showing that part.
    Pass the object when clicking the cell, inside: – tableView:didSelectRowAtIndexPath: and not when making the cell: -tableView:cellForRowAtIndexPath:
    Hope this helps

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

Sidebar

Related Questions

I'm trying to set up a UITableViewCell that can have an image in the
I have a view based app that works well. (In other words, I'm not
I have a tableview with cells that have a scrollview in them. The scrollview
i am trying and trying.... but no result yet. i have a view with
I am trying to have a logout page where is displays a messages and
I'm trying to have my Struts2 app redirect to a generated URL. In this
I'm trying to have a new layer appear above existing content on my site
I am trying to have one one layer, and center images within. I.E., if
I am trying to have a tooltip on multiple lines. how do i do
I am trying to have an element fade in, then in 5000 ms fade

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.