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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:15:48+00:00 2026-06-08T21:15:48+00:00

Hey guys sorry for the noob question but I am having a hard time

  • 0

Hey guys sorry for the noob question but I am having a hard time initializing my self created classes for an iphone game I’ve started making. Before I started actually developing my game I ran a quick test to see if what I have already would work, and the class that I was testing wouldn’t initialize. Here is what I have:

    @implementation Game
    SceneController *sceneController;

    +(id)scene {...} // just the default scene method created by cocos2d

    -(id)init{
        if((self=[super init])){
            [[sceneController performSelector:@selector(alloc)]performSelector:@selector(init)];
            CGSize size = [[CCDirector sharedDirector] winSize];
            CCLabelTTF *label=[CCLabelTTF labelWithString:[NSString stringWithFormat:@"%i",[sceneController performSelector:@selector(xxx)]] fontName:@"Marker Felt" fontSize:64];
            [self addChild: label];
        }
        return self;
    }


    // IN ANOTHER CLASS
    @implementation SceneController
    int xxx; // not a real variable just used for the test

    -(id)init{
        if((self=[super init])){
            xxx=432;
        }
        return self;
    }

    -(int)xxx{
        return xxx;
    }

My problem is that instead of the label reading 432 like it should it just says 0. Can anyone help me.

  • 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-08T21:15:49+00:00Added an answer on June 8, 2026 at 9:15 pm

    Looks like you haven’t contructed your SceneController object correctly.

    In your init method of Game, you need to make a call like this:

    sceneController = [[SceneController alloc] init];

    instead of this:

    [[sceneController performSelector:@selector(alloc)]performSelector:@selector(init)];

    Then your sceneController instance variable is properly initialised and your init method will have been called.

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

Sidebar

Related Questions

Hey guys, sorry for this probably fairly simple question but I'm starting to get
Hey guys sorry this is a pretty long question but I cannot call printPASSInfo()
hey guys having this really simple problem but cant seem to figure out have
Hey guys, sorry for, but I'm new to doubly-linked lists and was wondering if
Hey guys, sorry I'm kind of new to programming, but I had a small
hey guys , i know this is a stupid question but i hanged in
Hey guys sorry to ask but i need help with this query please I've
Hey guys sorry I was looking around but none of the expected expression error
Hey guys I wanted to create a JScrollPane but it won't work... and I
Hey guys (and gals) I'm having a problem using Assembly GetExportedTypes() in .NET 4.0.

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.