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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:17:52+00:00 2026-05-20T11:17:52+00:00

I am trying to access and change a array from a different class file.

  • 0

I am trying to access and change a array from a different class file. When using a NSLog, I get a result of (null). Below is my code:

RootViewController.h

NSMutableArray *listOfItems;
@property (nonatomic, retain) NSMutableArray *listOfItems;

RootViewController.m

@synthesize listOfItems;
listOfItems = [[NSMutableArray alloc] init];
[listOfItems addObject:@"One"];
[listOfItems addObject:@"Two"];
[listOfItems addObject:@"Three"];

SecondViewController.m

RootViewController *test = [[RootViewController alloc] init];
NSLog(@"Results: %@", test.listOfItems);

I get the following results in my console: Results: (null)

Thanks in advance,
Coulton

P.S. Obviously I have left out a bunch of code. I just tried to make it easier to read. If you need to see anything else, I would be more than happy to post more. Just ask

EDIT #1:

I am getting hundreds of NSLog Messages that look something like this:

*** __NSAutoreleaseNoPool(): Object 0x4e39020 of class __NSArrayI autoreleased with no pool in place - just leaking

And here’s my init code:

- (id) init {

//NSLog(@"%@", theUserID);
// Set up database connection
NSString *myDB = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"];
database = [[Sqlite alloc] init];
[database open:myDB];

//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];

// Add to array to display in the tableView
NSArray *listOfItemsTwo = [database executeQuery:@"SELECT * FROM albums"];  
for (NSDictionary *rowone in listOfItemsTwo) {
    NSString *getName = [rowone valueForKey:@"name"];
    if (getName != NULL) {
        [listOfItems addObject:getName];
        [getName release];
    }
}
return self;

}

  • 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-20T11:17:53+00:00Added an answer on May 20, 2026 at 11:17 am

    I guess you reversed RootViewController.m and RootViewController.h snippets right?

    Are you sure that the

    listOfItems = [[NSMutableArray alloc] init];
    

    gets called? Maybe you can put a breakpoint there.

    EDIT: Order of RootViewController.m and RootViewController.h has been fixed in the question. It’s not clear from the question where the above line is in the code. That’s a important piece of information.

    EDIT2: Example of init method.

    @implementation RootViewController
    - (id) init
    {
        listOfItems = [[NSMutableArray alloc] init];
        [listOfItems addObject:@"One"];
    
        return self;
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access/change the properties of a class' Parent through Reflection. If
Hi I'm trying to access a WCF service which returns a JSON Array using
I am trying to access HTML elements by their id from an array of
Trying to access a Servlet from a button on HTML page //Html Page FORM
I am trying to access all the data from database listOfFolder table folder and
I am trying to access a file for xml parsing with this: InputStream inputStream
I'm trying to pass an array of integers from c# to c++ via a
I am trying to delete certain key/value pairs from a hash, but I get
I am trying to access items of an array in a model and it's
I have an array of items coming back from the service. I'm trying to

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.