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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:40:43+00:00 2026-05-27T23:40:43+00:00

I am trying to push to final view where the whole information about item

  • 0

I am trying to push to final view where the whole information about item will be shown.

- (void)tableView:(UITableView *)atableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Item *itemObj; //object that holds data for cell for current view
ItemShow *itemOverViewObj; //data object for the next view 

if(atableView==self.tableView)
{
    //ordinary tabeView
    itemObj=[self.itemsArray objectAtIndex:[indexPath row]];
}
else
{
    //filtered with search tableView
    itemObj=[self.filteredItems objectAtIndex:[indexPath row]];
}

//The array which will store the data for overview 
NSMutableArray *itemsOverViewArr=[[NSMutableArray alloc]initWithCapacity:1];
DBAccess *access=[[DBAccess alloc]init];

//method for fetching data from db and inserting into array
itemsOverViewArr=[access getItemsOverView:itemObj.itemID];
[access closeDataBase];
[access release];

//here is the evil.
itemOverViewObj=[itemsOverViewArr objectAtIndex:[indexPath row]];
[itemsOverViewArr release];
    ItemOverView *iov=[[ItemOverView alloc]initWithNibName:@"ItemOverView" bundle:nil];
    iov.title=self.nominal;
    [iov setItemShow:itemOverViewObj];
    [self.navigationController pushViewController:iov animated:YES];
    [iov release];
}

What I’ve checked before:

Select in the method getItemsOverView works for 100%.
itemObj.itemID fetches the right int.

The problem originating in
itemOverViewObj=[itemsOverViewArr objectAtIndex:[indexPath row]];

The error: * Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]’

getItemsOverview meth 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,dateComment,itm.mintage,dc.dateCode as dateCode,iaval.availability as avalibility,iaval.quality as quality,itm.Mintmark,itm.specialRemark\
                                     from items itm\
                                     join itemAvailability iaval on iaval.itemID=itm.itemID\
                                     join dateCultures 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);
        char *mintMark=(char *)sqlite3_column_text(statement, 2);
        char *masterMark=(char *)sqlite3_column_text(statement, 3);
        itemShow.rarity=sqlite3_column_int(statement, 4);
        itemShow.availability=sqlite3_column_int(statement, 5);
        itemShow.quality=sqlite3_column_int(statement, 6);
        char *mintage=(char *)sqlite3_column_text(statement, 7);

        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";



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

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

return itemsArray;
}

Thank you in advance

  • 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-27T23:40:43+00:00Added an answer on May 27, 2026 at 11:40 pm

    The exception message says it all: You are trying to access the second item (index 1) in itemsOverViewArr but this array only contains one item (index 0).

    Why that is so only you can tell since you don’t show us the relevant code. But it sure looks like [access getItemsOverView:itemObj.itemID] returns an array containing 1 element.

    Also, you have at least one memory leak in your code. The array created by NSMutableArray *itemsOverViewArr=[[NSMutableArray alloc]initWithCapacity:1]; is no longer reachable after the line itemsOverViewArr=[access getItemsOverView:itemObj.itemID]; and thus cannot be released. The fact that you are releasing itemsOverViewArr later is probably also a memory management error (in this case an overrelease) because getItemsOverView: should return an autoreleased object. (Btw, you should not name such methods get... as this naming convention implies in Cocoa that the method returns its results via a pointer to one of the method’s arguments.)

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

Sidebar

Related Questions

I'm trying to push a view controller like so: SampleViewControllerB *svcb = [self.storyboard instantiateViewControllerWithIdentifier:@viewB];
I am trying to push a view controller from inside a callback block. The
im trying to push some view from my modal view. Im trying doing the
I'm trying to push a new view on my navigation controller using: -(IBAction)switchPage:(id)sender {
I am trying to push in a new view controller with the code: [self.navigationController
Im trying push some data into a CRM system via an XML import. I
I am getting this error when I am trying push my files into heroku
I'm trying to push a Flask application into Heroku. But if i start the
I'm trying to push a Lua class object onto the stack. The pointer to
I am trying to push an app to a jailbroken iPhone for development testing.

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.