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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:47+00:00 2026-05-23T07:44:47+00:00

In my app.i have some classes and inside one class I am calling method

  • 0

In my app.i have some classes and inside one class I am calling method in other class. In my other class I have a table view and an array “data”. When the query is executed in this method then I am adding the data obtained from the execution of the query to the array and then I am calling reload data for the table view. But to my surprise table view is not getting reloaded and I am not getting any sort of data on the table view. It is showing just a blank table view.

The method which is called from other class:

-(void)searchImagesInCategory:(NSString *)string
{
    data=[[NSMutableArray alloc]init];
    string1=string;    
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory= [paths objectAtIndex:0];
    NSString *path=[documentsDirectory stringByAppendingPathComponent:@"Table.sqlite"];

    //Open the database
    //might have to make database as property

    if(sqlite3_open([path UTF8String], &dataBase) ==SQLITE_OK)
    {
        sqlite3_stmt *statement;
        NSString *strSQL = [[NSString alloc]init];
        strSQL = @"select ImageName from tblLanguageElement where Category='";
        strSQL = [[strSQL stringByAppendingString:string1] stringByAppendingString:@"'"];

        const char *bar = [strSQL UTF8String]; 
        //strSQL = [strSQL stringByAppendingString:"''"];
        //NSLog(strSQL);
        if(sqlite3_prepare(dataBase, bar, -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW) 
            {
                NSLog(@"%@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]);
                [data addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]];
            }

            tableView1.delegate=self;
            tableView1.dataSource=self;
        }

    }
    [tableView1 reloadData];
}

My cell for row at index path method:-

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];

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

    cell.imageView.image= [UIImage imageNamed:[data objectAtIndex:indexPath.row]];
    return cell;        
}

Why i am not getting the reloaded Table view.Please help.

Thanks,

Christy

  • 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-23T07:44:47+00:00Added an answer on May 23, 2026 at 7:44 am

    In your method you are re-initializing your “data” array. Try making this a local variable by declaring it in your header file and then in your viewDidLoad method call:

         data= [[NSMutableArray alloc]init];
    

    Also there is no need to reset the delegate and data source. Just do it once and leave it.

    This is an edit from something else I have seen. You need to bind your variable and not just append the string. Here is an example….

    - (NSMutableArray*) getAllImagesForCategory:(NSString*)category {
    NSMutableArray *tempArray = [[NSMutableArray alloc]init]autorelease];;
    
       const char *sqlStatement = "select ImageName from tblLanguageElement where Category=?";
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
    
        sqlite3_bind_text(compiledStatement,1,category); //this is where you put your variable into the statement
    
        while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
            // Read the data from the result row
    
            NSString *imageName = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 1)];
    
    
            [tempArray addObject:imageName];
    
        }
    } else {
        NSLog(@"ERROR: Failed to select all images with message '%s'",sqlite3_errmsg(database));
    }
    
       // Release the compiled statement from memory
       sqlite3_finalize(compiledStatement);
       return tempArray;
    }
    

    So this is the SQL statement that will get the stuff from the database. To call this method you go something like this.

    _data = [self getAllImagesForCategory];
    [tableView1 reloadData];
    

    I hope this helps any questions just ask.

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

Sidebar

Related Questions

I have created some classes in a module, f.i. Request (app/models/api/request.rb) class Api::Request end
I have some classes in my app that don't require an ID to be
I have some data that I want to store somewhere in my Rails app
In my asp.net web app. I have three classes (inside app_code folder) under namespace
Lets say I have some simple classes for a twitter-like app: User Post A
I have two classes under QT, one to make a form, the other to
I have some java-app, and i want to establish a connection to some https
i have some WinForms app (Framework to develop some simple apps), written in C#.
i have some WinForms app (Framework to develop some simple apps), written in C#.
I have some settings in my app.config which I intend to be 'global' -

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.