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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:08:00+00:00 2026-05-26T22:08:00+00:00

I am calling a Singleton method that does not get called when I try

  • 0

I am calling a Singleton method that does not get called when I try doing this.
I get no errors or anything, just that I am unable to see the CCLOG message.

Under what reasons would a compiler not give you error and not allow you to call a method?

[[GameManager sharedGameManager] openSiteWithLinkType:kLinkTypeDeveloperSite];

The method is defined as follows:

-(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen
{

    CCLOG(@"WE ARE IN openSiteWithLinkType"); //I NEVER SEE THIS MESSAGE

    NSURL *urlToOpen = nil;

    if (linkTypeToOpen == kLinkTypeDeveloperSite) 
    {
        urlToOpen = [NSURL URLWithString:@"http://somesite.com"];    
    }

    if (![[UIApplication sharedApplication]openURL:urlToOpen])
    {
         CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]);
        [self runSceneWithID:kMainMenuScene];
    }

}

HERE IS THE CODE TO MY SINGLETON:

#import "GameManager.h"
#import "MainMenuScene.h"


@implementation GameManager
static  GameManager* _sharedGameManager = nil;
@synthesize isMusicON;
@synthesize isSoundEffectsON;
@synthesize hasPlayerDied;

+(GameManager*) sharedGameManager
{
@synchronized([GameManager class])
    {

        if (!_sharedGameManager) 
        {
            [[self alloc] init];
            return _sharedGameManager;
        }
        return nil;
    }

}


+(id)alloc
{

    @synchronized ([GameManager class])
    {
        NSAssert(_sharedGameManager == nil,@"Attempted to allocate a second instance of the Game Manager singleton");
        _sharedGameManager = [super alloc];
        return _sharedGameManager;
    }
    return nil;
}

-(id)init
{
    self = [super init];
    if (self != nil)
    {
        //Game Manager initialized
        CCLOG(@"Game Manager Singleton, init");
        isMusicON = YES;
        isSoundEffectsON = YES;
        hasPlayerDied = NO;
        currentScene = kNoSceneUninitialized;
    }

    return self;

}


-(void) runSceneWithID:(SceneTypes)sceneID
{
    SceneTypes oldScene = currentScene;
    currentScene = sceneID;
    id sceneToRun = nil;


    switch (sceneID) 
    {
        case kMainMenuScene:
            sceneToRun = [MainMenuScene node];
            break;

        default:
            CCLOG(@"Unknown Scene ID, cannot switch scenes");
            return;
            break;
    }

    if (sceneToRun == nil)
    {

        //Revert back, since no new scene was found
        currentScene = oldScene;
        return;
    }




    //Menu Scenes have a value of < 100
    if (sceneID < 100) 
    {
        if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)
        {
            CGSize screenSize = [CCDirector sharedDirector].winSizeInPixels;
            if (screenSize.width == 960.0f)
            {
                //iPhone 4 retina
                [sceneToRun setScaleX:0.9375f];
                [sceneToRun setScaleY:0.8333f];
                CCLOG(@"GM: Scaling for iPhone 4 (retina)");
            }
            else
            {
                [sceneToRun setScaleX:0.4688f];
                [sceneToRun setScaleY:0.4166f];
                CCLOG(@"GM: Scaling for iPhone 3G or older (non-retina)");
            }

        }    

    }


    if ([[CCDirector sharedDirector] runningScene] == nil)
    {
        [[CCDirector sharedDirector] runWithScene:sceneToRun];
    }
    else

    {
        [[CCDirector sharedDirector] replaceScene:sceneToRun];

    }

}


-(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen
{

    CCLOG(@"WE ARE IN openSiteWithLinkType");

    NSURL *urlToOpen = nil;

    if (linkTypeToOpen == kLinkTypeDeveloperSite) 
    {
        urlToOpen = [NSURL URLWithString:@"http://somesite.com"];    
    }

    if (![[UIApplication sharedApplication]openURL:urlToOpen])
    {
         CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]);
        [self runSceneWithID:kMainMenuScene];
    }

}


-(void) test
{


    CCLOG(@"this is test");

}
@end
  • 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-26T22:08:00+00:00Added an answer on May 26, 2026 at 10:08 pm

    Perhaps sharedGameManager is returning nil? This won’t cause an error.

    Edit: The issue is in the new code you posted:

    if (!_sharedGameManager) {
        [[self alloc] init];
        return _sharedGameManager;
    }
    return nil;
    

    If _sharedGameManager is non-nil, this will return nil. You want:

    if (!_sharedGameManager) {
        [[self alloc] init];
    }
    return _sharedGameManager;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
When I try to use this one approach of singleton: class Singleton(object): def __init__(self,
i have a method that creates a Process calling a console app. double myProcess()
I have a singleton called SettingsManager in my app that should take care of
Calling Html.RenderPartial(~/Views/Payments/MyControl.ascx); from a view works if MyControl.ascx is a control that directly inherits
Calling getActionBar returns null . This has been frequently reported so I've made sure
When calling functions that always throw from a function returning a value, the compiler
Scenario: I have @Singleton UserFactory ( @Stateless could be) , its method createSession() generating
This isn't exactly a singleton, but it's close, so I imagine it's common. I
I have a singleton logger that contains a vector. Objects from outside can append

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.