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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:40:31+00:00 2026-05-20T12:40:31+00:00

hoping for advice on something. I have a Levels Engine class that creates an

  • 0

hoping for advice on something.

I have a Levels Engine class that creates an NSMutable Array called levelsArray.

I am passing the data to a Levels View Controller which is working just fine.

I also have a Particle Emitter class to which I am hoping to pass the level data.

However I am constantly being told that the count level of the array is 0 when I pass it to the Particle Emitter class.

The array has been setup properly:

    **LevelsEngine.h**  
    @interface
    LevelsEngine : NSObject {   
    NSMutableArray *levelsArray;         }

    @property (retain) NSMutableArray
    *levelsArray;  




    **LevelsEngine.m**  
    @synthesize levelsArray;  
    LevelsArray =[NSMutableArray array];


    **Code used in ParticleEmitter.m**   
    newlevelsArray = [NSMutableArray array];  
    newlevelsArray=view.levelsArray;

Am I right in thinking I am having this error because I am trying to pass the array data from one NSObject to another and not to a view controller?If so how can I pass the data?

  • 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-20T12:40:32+00:00Added an answer on May 20, 2026 at 12:40 pm

    Couple of things.

        **Code used in ParticleEmitter.m**   
        newlevelsArray = [NSMutableArray array];  
        newlevelsArray=view.levelsArray;
    

    The first line is creating a new array.
    The 2nd line is assigning newlevelsArray to be a pointer to the array in view.levelsArray, leaving the object you created in line #1 orphaned.

    I think you were intending the 2nd line to be a field by field copy of the array, but assignments of objects don’t work that way.

    You can fix this by 2 things.

    1) Remove the first line newlevelsArray = [NSMutableArray array];

    2) Change the 2nd line to `newlevelsArray = [view.levelsArray copy];

    This will actually do a copy, which is probably what you want since you can then go ahead and modify newlevelsArray in ParticleEmitter.m without changing the value in view.

    Important note: don’t forget to create a -dealloc: method in your Particle emitter class which releases newlevelsArray:

    -(void)dealloc {
       if (newlevelsArray) [newlevelsArray release];
       [super dealloc];
    }
    

    An alternative solution is to use setters.

    Instead of:

    2) Change the 2nd line to newlevelsArray = [view.levelsArray copy];

    Do:

    2) Change the 2nd line to this.newlevelsArray = view.levelsArray;
    Where you have to define newlevelsArray to be a property of the ParticleEmitter class using

    @property (copy) NSMutableArray * newlevelsArray;

    Note the use of “copy” instead of “retain”. This will do a field by field copy of the array, which is most likely advisable for containers of mutable objects.

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

Sidebar

Related Questions

I'm hoping to find out what tools folks use to synchronize data between databases.
I'm hoping there's something in the same conceptual space as the old VB6 IsNumeric()
I'm hoping that someone has found a way of doing this already or that
I am hoping to dynamically update a ModelForm's inline Meta class from my view.
I'm hoping that it isn't to pass each as a parameter to the controller
I was hoping to make a Rails app usable both as an Engine and
I have a new C++/ATL DLL (x86 and x64) that I'd like to include
Hoping someone can provide an answer with this, although it's not 100% programming related.
I'm hoping there's a way to avoid custom configuration files if an application runs
I'm hoping someone has seen this before because I can't for the life of

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.