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 5929811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:28:25+00:00 2026-05-22T14:28:25+00:00

I have a problem, I make a TabBAr application (with navigationbar), the bar bar

  • 0

I have a problem, I make a TabBAr application (with navigationbar), the bar bar is a list of favorits stored in an array.
My problem is that if I change ViewController and add object to array, when I come back to UITableView it isn’t reloaded…
This is the class:

–

 (void)viewDidLoad {
    [super viewDidLoad];

    [self readArgFromDatabaseSottoArgomenti];
    [self VisualizzaPreferiti];

}

- (void)viewWillAppear:(BOOL)animated {
    [self.tableView reloadData];
}

-(void) readArgFromDatabaseSottoArgomenti {

    databasePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ARGOMENTI.sqlite"];

    sqlite3 *databaseDesc;
    // Init the argoments Array
    arraySottoArgomenti = [[NSMutableArray alloc] init];

    // Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &databaseDesc) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        // const char *sqlStatement = "select * from DESCRIZIONE ";
        const char *sqlStatement = [[NSString stringWithFormat:@"SELECT * from DESCRIZIONE ORDER BY id"] UTF8String];
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(databaseDesc, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            // Loop through the results and add them to the feeds array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
                // Read the data from the result row
                NSString *aID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
                NSString *aIDArgomento = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
                NSString *aDescrizione = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
                NSString *aTesto = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];

                // Create a new argoments object with the data from the database
                ContenutoObjectDescrizione *contenutoSottoArgomenti = [[ContenutoObjectDescrizione alloc] initWithName:aID idArgomento:aIDArgomento descrizione:aDescrizione testo:aTesto];
                [arraySottoArgomenti addObject:contenutoSottoArgomenti];

                [contenutoSottoArgomenti release];
            }
        }


        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);

    }
    sqlite3_close(databaseDesc);

}

- (void) VisualizzaPreferiti {

    int i;

    NSUserDefaults *userPref = [NSUserDefaults standardUserDefaults];
    array = [userPref objectForKey:@"array"];


    NSLog(@"Retain Count %d Numero ID Array %d",[array retainCount],[array count]);



    NSMutableArray *arrayOggettoPreferito;
    arrayOggettoPreferito = [[NSMutableArray alloc] init];

    ContenutoObjectDescrizione *oggetto = [[ContenutoObjectDescrizione alloc] init];

    for (oggetto in arraySottoArgomenti) {
        for (i=0; i<[array count]; i++) {

            if ([[array objectAtIndex:i] intValue] == [oggetto.id intValue]) {
                [arrayOggettoPreferito addObject:oggetto];

                NSLog(@"ID %@ IDMateria %@ Titolo %@",oggetto.id,oggetto.idArgomento,oggetto.descrizione);
            }
        }
    }   

    listaPref = arrayOggettoPreferito;

    arrayOggettoPreferito=nil;
    [arrayOggettoPreferito release];
    [oggetto release];  

}

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [listaPref count];
}


// Customize the appearance of table view cells.
- (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];
    }

    ContenutoObjectDescrizione *oggettoCercato = [[ContenutoObjectDescrizione alloc] init];
    oggettoCercato = [listaPref objectAtIndex:[indexPath row]];

    cell.textLabel.text = oggettoCercato.descrizione;
    NSLog(@"%@",oggettoCercato.descrizione);


    return cell;
}

#pragma mark -
#pragma mark Table view delegate

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

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    TestoViewController *testoViewController = [[TestoViewController alloc] initWithNibName:@"TestoView" bundle:nil];
    [self.navigationController pushViewController:testoViewController animated:YES];

    ContenutoObjectDescrizione *oggettoCercato = [[ContenutoObjectDescrizione alloc] init];
    oggettoCercato = [listaPref objectAtIndex:[indexPath row]];

    testoViewController.idPreferito = oggettoCercato.id;

    testoViewController.title = oggettoCercato.descrizione;

    NSString *descrizioneWeb = oggettoCercato.testo;

    NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];

    [testoViewController.vistaWeb loadHTMLString:descrizioneWeb baseURL:baseURL];
    [testoViewController release];


}

#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}
  • 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-22T14:28:26+00:00Added an answer on May 22, 2026 at 2:28 pm

    Simply calling reloadData doesn’t make it do anything unless you update your datasource. In viewWillAppear, you will need to call VisualizzaPreferiti again before you call reloadData.

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

Sidebar

Related Questions

i have a problem i make a wpf application its running well.but i want
I have an iPhone application that's using Navigation Controller to display the top bar
I have the following problem. My application has a tab bar at the bottom
I am trying to make a Tab Bar application where one of the ViewController
I have a problem trying to make a list from a acts_as_taggable_on tag_list I
I have to make a simple layout in android but have problem with the
I have problem with base classes in WPF. I try to make a base
I have a problem with datePicker. When a make a new text field with
I have a problem. I built a script to make a request to an
I have a huge problem with this method im trying to make. I have

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.