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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:58:56+00:00 2026-06-07T02:58:56+00:00

I have a local SQLite Database and need to return a large number of

  • 0

I have a local SQLite Database and need to return a large number of records. It takes a several seconds to load so I want to add an activity indicator. The activity indicator seems to be running as it should but the problem is the pool isn’t allowing the arrays to return any value see below.

  - (void)viewDidLoad
    {
        [super viewDidLoad];

        activityIndicator = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
        activityIndicator.frame = CGRectMake(0.0, 0.0, 48.0, 48.0);
        activityIndicator.center = self.view.center;
        [self.view addSubview:activityIndicator];

        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
         [activityIndicator startAnimating];            


     [self performSelectorInBackground:@selector(loadData) withObject:nil];   

    }
//What I need to load from SQLITE
-(void)loadData {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Path to the database

//CODED HERE FOR DATABASE TO OPEN AND QUERY HERE TO BUILD ARRAYS

        NSString *firstField = [NSString stringWithUTF8String:cFirst];
                NSString *secondField = [NSString stringWithUTF8String:cSecond];
                NSString *thirdField = [NSString stringWithUTF8String:cThird];


                [FirstArray addObject:firstField];
        [SecondArray addObject:secondField];
                [ThirdArray addObject:thirdField];  

   //Checking to see if records are being added to the arrays
NSString *recordAdded = [NSString stringWithFormat:@"%@ - %@ - %@", firstField, secondField, thirdField];

                    NSLog(@"Song: %@", recordAdded);

    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;     
    [activityIndicator stopAnimating];

  [pool release];   
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

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

        NSString *firstValue = [firstArray objectAtIndex:indexPath.row]; 
        NSString *secondValue = [secondArray objectAtIndex:indexPath.row];
        NSString *thirdValue = [thirdArray objectAtIndex:indexPath.row];

        NSString *details = [NSString stringWithFormat:@"%@ - %@", secondValue, thirdValue];


        cell.textLabel.text = cellValue;

        cell.detailTextLabel.text = details ;

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}

When I’m looking at the debugger I see that the arrays are being built as the activity indicator is going. The problem is that I think the pool release is releasing my arrays too.

The code returns the query in the table view fine when I don’t add the Pool and activity indicator.

Can anyone help to point me in the right direction to not release the arrays if that’s what is happening here? Any kind of help would be much appreciated. 🙂

—Also—
After looking around more I found that I have to pass the arrays back to the main thread. This is what I gather from searching online.

[self performSelectorOnMainThread:@selector(done:) withObject:cellData waitUntilDone:NO];

How would I go about loading the table with these arrays?

  • 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-06-07T02:58:58+00:00Added an answer on June 7, 2026 at 2:58 am

    Not sure about your pool releasing the array, your code seems pretty direct. You may want to check whether you are really getting any data from your database.

    However, I notice that you stop animating the activity indicator in the background thread. UI activity should be done in the main thread. I just did this coding last night and solved my problem using this thread. Put your stop animating code in the selector specified by performSelectorOnMainThread.

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

Sidebar

Related Questions

I have an sqlite database whose data I need to transfer over the network,
I have a ListView with custom adapter which is populated from local sqlite database.
I have an android app that maintains a local SQLite database of different geographic
I have a local sqlite server. The SQL database only contains a table called
I have my sqlite database. now i want syncing with icloud. I read blogs
So I have a local SQLite table breadcrumbs being created on the Android device.
I have a local Database running on localhost:3306, which I access with MySQL Workbench.
I have a local repository. I created the whole application, but now I want
I am attempting to insert data into a local SQLITE database file from a
I am working on a Cocoa application which talks to a local SQLite database

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.