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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:50:35+00:00 2026-05-28T06:50:35+00:00

Ok this is third day of working with Xcode so please be nice. I

  • 0

Ok this is third day of working with Xcode so please be nice.

I am trying to set up a simple table to display records from an existing sqlite database. I’ve got as far as loading the database into a NSMutableArray and have verified the size is correct, but I can’t loop through it and get the data properly out. All that displays is the last record of the table.

Here is the sample code:

    while([results next]) {

        self.subject_id = [results stringForColumn:@"SUBJECT_ID"];
        self.subject = [results stringForColumn:@"SUBJECT"];
        self.category = [results stringForColumn:@"CATEGORY"];

        [subjects addObject:self];
        NSLog(@"AFTER record: %@ - %@ - %@", self.subject_id, self.subject, self.category);        

    }

As the loop prints out to the log I verify that the correct data is being looped through.

Then I run this immediately after populating the array and I get the same last entry, each time:

    //PULL UP THE THINGY AND SEE IF IT WORKS

    Subject *sub; 

    int x = 0;    
    for (sub in subjects){

        Subject *xsub = [subjects objectAtIndex:x];

        NSLog(@"    %i sub data ------- %@, -----  %@", x, xsub.subject, xsub.category);
        x = x+1;
    };

    sub = [subjects objectAtIndex:50];

    NSLog(@"    sub data ------- %@, -----  %@", sub.subject, sub.category);

I even tried specifically pulling up a record from the Array like this but I get the same last record instead of the record I asked for:

sub = [subjects objectAtIndex:50];

“Subject” is a class giving the field names of my table. I haven’t used the entity feature yet.

My header file declares the field names like this:

@property (nonatomic, retain) NSString * subject_id;
@property (nonatomic, retain) NSString * subject;
@property (nonatomic, retain) NSString * category;

I used the FMDB wrapper to get the data from my database and pieced together the classes from a couple different tableView examples such as the Animals one.

Can anyone give me some direction on how to debug this?

  • 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-28T06:50:35+00:00Added an answer on May 28, 2026 at 6:50 am

    My guess would be either that each array object has had the same text loaded into it, or that the same object has been added to the array multiple times.

    Either way, I’d take a long hard look at the array loading code.

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

Sidebar

Related Questions

I've been trying to get this working correctly all day, its nearly complete just
I'm now on my third full day this week of trying to get OpenCV
Third try at fixing this tonight - trying a different approach than before now.
This is taken directly from my Django template: {% for day in days %}
From Day One I was told that each third-party iOS app was perfectly sand-boxed
Today is my first day working with SQL so please bear with me for
I have a table that displays two columns from a table and a third
I know about this question: Which (third-party) debug visualizers for Visual Studio 2005/2008 do
first of all this is my third question about web services here and i
THIRD EDIT: I now believe that this problem is due to a SOAP version

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.