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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:25:31+00:00 2026-05-31T15:25:31+00:00

I have a class defined with five (5) properties. I want to take those

  • 0

I have a class defined with five (5) properties. I want to take those properties and place them in a NSMutableArray (listOfSites). This is my code:

FMResultSet *rs = [fmdb executeQuery: @"SELECT SITE_ID, SITE_DESC, DATE FROM SiteData WHERE SITE_ID <> '0'"];
while([rs next])  {
    sArray *sa = [[sArray alloc] init];
    sa.sSiteID = [rs stringForColumnIndex:0];
    sa.sJobDesc = [rs stringForColumnIndex:1];
    sa.sJobDate = [rs stringForColumnIndex:2];

    [listOfSites addObject:sa];  //  add class object to array
}
[fmdb close];

The sArray (not an array, but the name of the class) has the correct content, but the “addObject: sa” message does NOT place the class into the class.

What am I doing wrong?

UPDATE: declaration of “listOfSites”:

@interface slSQLite : NSObject  {

    sqlite3 *dataBase;  //  declare pointer to database
    UILabel *status;
    BOOL newFlag;
    int siteCount;
    int seqNbr;
    NSDate *date;
    NSString *dbCmd;
    NSMutableArray *listOfSites;  //  populated by sqlite

}

Initialization of “listOfSites”:

@implementation slAppDelegate  {   }

@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  {

    slSQLite *sqlite = [[slSQLite alloc] init];  //  allocate class
    [sqlite checkForDatabase];  //  check for database

    NSMutableArray *listOfSites = [[NSMutableArray alloc] init];

    return YES; 
}
  • 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-31T15:25:32+00:00Added an answer on May 31, 2026 at 3:25 pm

    You are using two different variables named listOfSites. The first one is a local variable in didFinishLaunchingWithOptions:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  {
        //...
        NSMutableArray *listOfSites = [[NSMutableArray alloc] init];
        //...
    }
    

    The second one is an instance variable one the class slSQLite:

    @interface slSQLite : NSObject {
        // ...
        NSMutableArray *listOfSites;  //  populated by sqlite
    }
    

    When you initialize the variable listOfSites that is in didFinishLaunchingWithOptions,, the there variable that is in slSQLite remains unchanged and non initialized.

    So you should initialize the array before using it:

    listOfSites = [[NSMutableArray alloc] init];
    while([rs next])  {
        sArray *sa = [[sArray alloc] init];
        sa.sSiteID = [rs stringForColumnIndex:0];
        sa.sJobDesc = [rs stringForColumnIndex:1];
        sa.sJobDate = [rs stringForColumnIndex:2];
    
        [listOfSites addObject:sa];
    }
    NSLog(@"The array listOfSites contains %d items, listOfSites.count);
    

    PS. sa is an object and not a class. It is an instance of the class sArray.

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

Sidebar

Related Questions

We have a class Car defined like this in a car.rb file class Car
Let's say that I have a class defined in moduleA.py which I want to
I have a class defined like this: public class StateMachineMetadata<T> where T: struct {
If I have this class defined, how do I access the someObject property in
I have a class defined like this : @interface ServerCall : NSObject { //
I have a class defined like this (scheme) : myClass = BaseClass.extend({ method1 :
I have a class defined like this: template< class TBoundingBox > class BoundingBoxPlaneCalculator {
I have a class defined like this: class MyClass { int x; public: MyClass(int
I have a class defined in a gem by Diff::LCS and I want to
If I have a class defined as classdef myclass properties foo = 3; bar

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.