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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:33:34+00:00 2026-05-28T04:33:34+00:00

I am trying to fill up an NSmutableAray with data from sqlite database. ItemShow

  • 0

I am trying to fill up an NSmutableAray with data from sqlite database.

ItemShow class:

@interface ItemShow : NSObject 
{
NSInteger itemID;
NSString *itemYear;
NSInteger rarity;
NSString *mintage;
NSInteger availability;
NSInteger quality;
NSString *mintMark;
NSString *masterMark;
NSString *dateCode;
NSString *dateDescription;
}

Getters/setters are ok

Method in DBAccess class:

-(NSMutableArray*)getItemsOverView:(int)itemID
{
NSMutableArray *itemsArray=[[[NSMutableArray alloc]init]autorelease];
const char *sqlItems=sqlite3_mprintf("SELECT itm.itemID,itm.itemYear,itm.rarity,itm.mintage,iaval.availability as avalibility,iaval.quality as quality,itm.Mintmark,itm.masterMark,dc.dateCode,dc.dateDescription\
                                     from items as itm\
                                     join itemAvailability as iaval on iaval.itemID=itm.itemID\
                                     join dateCultures as dc ON dc.dateCultureID=itm.dateCulture\
                                     WHERE itm.itemID=%i",itemID);
sqlite3_stmt *statement;
int sqlResult = sqlite3_prepare_v2(database, sqlItems, -1, &statement, NULL);
if ( sqlResult== SQLITE_OK)
{
    while (sqlite3_step(statement) == SQLITE_ROW)
    {
        ItemShow *itemShow=[[ItemShow alloc]init];
        itemShow.itemID=sqlite3_column_int(statement, 0);
        char *itemYear=(char *)sqlite3_column_text(statement, 1);
        itemShow.rarity=sqlite3_column_int(statement, 2);
        char *mintage=(char *)sqlite3_column_text(statement, 3);
        itemShow.availability=sqlite3_column_int(statement, 4);
        itemShow.quality=sqlite3_column_int(statement, 5);
        char *mintMark=(char *)sqlite3_column_text(statement, 6);
        char *masterMark=(char *)sqlite3_column_text(statement, 7);
        char *dateCode=(char *)sqlite3_column_text(statement, 8);
        char *dateDescription=(char *)sqlite3_column_text(statement, 9);

        itemShow.itemYear=(itemYear)?[NSString stringWithUTF8String:itemYear]:@"";
        itemShow.mintMark=(mintMark)?[NSString stringWithUTF8String:mintMark]:@"";
        itemShow.masterMark=(masterMark)?[NSString stringWithUTF8String:masterMark]:@"";
        itemShow.mintage=(mintage)?[NSString stringWithUTF8String:mintage]:@"Unknown";
        itemShow.dateCode=(dateCode)?[NSString stringWithUTF8String:dateCode]:@"";
        itemShow.dateCode=(dateDescription)?[NSString stringWithUTF8String:dateDescription]:@"";

        [itemsArray addObject:itemShow];
        [itemShow release];

    }
    sqlite3_finalize(statement);
}
else
{
    [self dbConnectionError];
}

return itemsArray;
}

code in ViewDidLoad

DBAccess *dbAccess=[[DBAccess alloc]init];
self.dataArr=[dbAccess getItemsOverView:itemID];
   // ItemShow *itmShow=[dataArr objectAtIndex:1];
NSLog(@"%d",[dataArr count]); //returns 1. So, empty array
[dbAccess closeDataBase];
[dbAccess release];

Same construction works fine in other views, but now it gives error – empty array out of bounds.

What was checked

  1. Select works. checked it in SQLiteStudio
  2. itemID is int and the view getting it correct from previous view like it gets title.
  • 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-28T04:33:34+00:00Added an answer on May 28, 2026 at 4:33 am

    Have resolved it by myself. Just made new method. Now it works

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

Sidebar

Related Questions

I am trying to fill out a DataGridView with data from a database. The
I'm trying to fill a asp.DataGrid with data from a DB2 database. The problem
I'm trying to fill a tableView with info extracted from an SQLite database... I've
I'm trying to fill a grid view using data from a db cursor using
I'm trying to fill the dropdown on run time from the database, whenever user
I am trying to fill a livecycle created form with form data from django.
Currently, I am trying to fill an SQLite database with tens of thousands of
hi m trying fill the combo box from cities database but i wan the
I have a custom class: @interface Player : NSObject { NSInteger mPlayerNo; } -(id)
I am trying to fill a form in a php application from a C#

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.