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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:34:24+00:00 2026-05-31T11:34:24+00:00

In my iphon app , I’m reading from sqlite db into NSMutableArray *sales and

  • 0

In my iphon app , I’m reading from sqlite db into NSMutableArray *sales and I want to assign the data in sales into a cell in TableView.
How can I do it?

Here is my code:
In Controller:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *result = nil;
    if ([tableView isEqual:self.myTableView]){
      static NSString *TableViewCellIdentifier = @"MyCells";
      result = [tableView dequeueReusableCellWithIdentifier:TableViewCellIdentifier];
      if (result == nil){
        result = [[UITableViewCell alloc]
                  initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier:TableViewCellIdentifier];
       }

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

    [appDelegate readSalesFromDatabase]; 

    // ***here is where I'm trying to retrive the data*** 
    // when I run the simulator, at this point I receive 'SIGABRT'
   =====>    result = [sales objectAtIndex:indexPath.row]; 
    }
    return result; 
}

In Delegate:

-(void) readSalesFromDatabase {

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
    // Setup the SQL Statement and compile it for faster access

          const char *sqlStatement = "select us.userID from UsersSale us  order by us.saleID";        


    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, 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
            NSInteger auserID = sqlite3_column_int(compiledStatement, 0); 

            // Create a new  Sale object with the data from the database                
            SelectFromList *sfl  = [[SelectFromList alloc] initWithName:auser];                                        

            // ***here is where I'm inserting the data to NSMutableArray *sales ** 
            [selectFromListController.sales insertObject:sfl atIndex:count];  

            [sfl release];

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

}
sqlite3_close(database);

}
@end

  • 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-31T11:34:25+00:00Added an answer on May 31, 2026 at 11:34 am

    First, consider calling ‘[appDelegate readSalesFromDatabase]’ on viewDidLoad or in your view controller’s init method as you’re invoking this for every row rendered. That’s probably not what you want for performance.

    Second, you should check to see what is in the ‘sales’ array and make sure there is data in it. If the indexPath.row value exceeds the size of the array, it’s likely that you’re not returning the actual and correct number of rows in ‘tableView:numberOfRowsInSection:’. In that case, you’re being asked for data that may not exist in your backing store.

    Also, you may want to think of your UITableView usage not as ‘assigning data into the table’s cell’ but instead, ‘return data for the particular cell that is being rendered currently’.

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

Sidebar

Related Questions

My iphone app downloads user specific data from our web server. How can I
An iPhone app which I am creating generates reports from a Core Data database
My iPhone app will download a large amount of data from a remote server.
My iPhone app currently uses core data. I want to create an online database
My iphone app getting json data from php server. 2 basic questions, just to
In iPhone App how to store UIImage converted into NSData to sqlite table in
My iphone app uses a SQLite database to store data. I have a table
On Iphone App start I start a background thread to receive some data from
In my iPhone App I want to implemented functionality as shown below user can
my iphone app crashes unexpectedly and looking at the crash log I can't tell

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.