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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:18:43+00:00 2026-06-09T16:18:43+00:00

I have a (probably) very slow and inefficient collage that I generate on a

  • 0

I have a (probably) very slow and inefficient collage that I generate on a particular view controller. It takes forever to load, so I am looking for suggestions that would either speed up my SQLite query (it’s searching BLOBs of saved images) or cause the SQL query method to be called after the viewcontroller loads, and then I’ll put an activity indicator while it’s loading.

Here are code snippets.

viewDidLoad:

- (void)viewDidLoad
{
    //generate photo collage
    wineryName = theWineOfCurrentWinery.winery;
    [self obtainImagesForWines:wineryName];

    //lots of other stuff
}

obtainImagesForWines function. This is controlling the photos that show up in one of 16 UIImageViews, there is a 4×4 block of them:

- (void) obtainImagesForWines:(NSString *)theWineryName {

sqlite3_stmt *stmt=nil;
sqlite3 *cruddb;

//sql command
const char *sql = "SELECT photo FROM wines WHERE winery=? AND photo NOT NULL ORDER BY RANDOM() LIMIT 16";

//Open db
sqlite3_open([path UTF8String], &cruddb);

int j=0;
if(sqlite3_prepare_v2(cruddb, sql, -1, &stmt, NULL) == SQLITE_OK) { 
    sqlite3_bind_text(stmt, 1, [theWineryName UTF8String], -1, SQLITE_TRANSIENT);
    while(sqlite3_step(stmt) == SQLITE_ROW) {
        UIImage *winePhoto;

        NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(stmt, 0) length:sqlite3_column_bytes(stmt, 0)];            

        if (data) {
            winePhoto = [UIImage imageWithData:data];
        }

        switch (j) {
            case 0:
                image1.image = winePhoto;
                break;
            case 1:
                image2.image = winePhoto;
                break;
            case 2:
                image3.image = winePhoto;
                break;
            case 3:
                image4.image = winePhoto;
                break;
            case 4:
                image5.image = winePhoto;
                break;
            case 5:
                image6.image = winePhoto;
                break;
            case 6:
                image7.image = winePhoto;
                break;
            case 7:
                image8.image = winePhoto;
                break;
            case 8:
                image9.image = winePhoto;
                break;
            case 9:
                image10.image = winePhoto;
                break;
            case 10:
                image11.image = winePhoto;
                break;
            case 11:
                image12.image = winePhoto;
                break;
            case 12:
                image13.image = winePhoto;
                break;
            case 13:
                image14.image = winePhoto;
                break;
            case 14:
                image15.image = winePhoto;
                break;
            case 15:
                image16.image = winePhoto;
                break;
            default:
                NSLog(@"wtf?");
        }
        j++;
    }
}
else {
    printf("I can't get the wine photo by ID!!: %s\n", sqlite3_errmsg(cruddb));
}
sqlite3_finalize(stmt);
sqlite3_close(cruddb);
}
  • 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-09T16:18:45+00:00Added an answer on June 9, 2026 at 4:18 pm

    In order to run this method in the background (in other words “after view did load”), I used the following code in viewDidLoad:

    [self performSelectorInBackground:@selector(obtainImagesForWines) withObject:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
I'm trying to do something which is probably very simple, I have a directory
Probably a very basic beginner question. Imagine the following situation: I have an ASP.NET
If you've used Google Wave or iGoogle you have probably seen that you can
i have another (probably unanswered) question about map views. I have a map view
I'm working on a larger Web based Project, that probably will have to handle
Probably a very basic question - I have 2 tables #favorites and #leaders ,
Ok, I have a question that I know is very opinionated (based on all
Error: End tag for 'optgroup' which is not finished. You have probably failed to
well i have most probably an extremly stupid problem but could not figure it

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.