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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:18:58+00:00 2026-06-07T15:18:58+00:00

As one might expect I’m new to Objective-C and Cocoa2d so this might be

  • 0

As one might expect I’m new to Objective-C and Cocoa2d so this might be painfully obvious but I can’t seem to get it to work in a way that makes sense.

What I’m trying to do is to make an array of 10 members (more will be added later) full of either [0,1,2,3] integers, later I want these numbers to be used for a level selection screen where 0 means the level is locked (not completed), and the numbers >0 represent the number of stars (out of three) and mean the level was completed, at the end of a level I want to change the array to reflect that the level was completed. For testing purposes I filled the array with “random integers” (0-3) as such (in LevelSelection.m):

NSMutableArray *LevelCompArray = [NSMutableArray arrayWithCapacity:10];
        for(int i = 0; i<10; i++){
            int x= (arc4random() % (4));
            [LevelCompArray addObject:[NSNumber numberWithInteger:x]];
        }

I have not alloced nor init the Array but it seems to work within the function itself -(id) init though I believe that is a the root of my problem.

My problem is simple, how do I transfer this array (and other data I will create as my game progresses) from class to class (e.g. from LevelSelection.m to LevelCompleted.m) and from function to function (e.g. -(id) init and -(void) launchLevel). Do I have a centralized file for data that all required classes can access? If that’s the case what’s with all the talk of a “.plist”? If not, do I transfer the data through methods to the target class(es)/ method(s)? How do I do that?

Any help is deeply appreciated, transferring me to a tutorial would also be incredibly useful.

  • 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-06-07T15:19:01+00:00Added an answer on June 7, 2026 at 3:19 pm

    One way to do it would be, as you said, have a bunch of global variables in a file that everyone #imports. You wouldn’t use a .plist file; rather, it would just be a .m like all your other source code.

    You could also pass the information to the constructor of any object that needs it. For example, you could do something like [[LevelSelection alloc] initWithCompletionArray:LevelCompArray]. Then, to make sure that every object has the right information in said array, use notifications.

    -(id) initWithStuff:(Stuff *s) {
        if(self = [super init]) {
            [[NSNotificationCenter defaultCenter] addObserver:self
                                                     selector:@selector(doStuff:)
                                                         name:@"LEVEL_COMPLETED"
                                                       object:anObject];
        }
    

    And then in doStuff: (which takes an NSNotification*), you’d have some logic to handle whatever happened, using the notification’s object.

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

Sidebar

Related Questions

I'm not very expert on how processors work, but one might imagine that it
According to the Qt documentation, QVariant::operator== does not work as one might expect if
In the following inline conditionals, one might expect an integer and a double to
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes
The obvious attempt is: Regex.Replace(input, @.$, X, RegexOptions.Singleline); This doesn't always work though. Consider
I've got another question, although I reckon this one might be a little less
In C++ one might use namespace to keep independent groups working in the same
I find it not so easy as one might think to start with TDD
I'm searching for strategies one might use to programmatically find files which may be
Sometimes in an application, one might compare the Message text of an exception. For

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.