开发者

Why wont my singleton property autocomplete?

开发者 https://www.devze.com 2023-03-06 17:49 出处:网络
Anyidea why autocomplete does not work on the spaceScene property? #import <Foundation/Foundation.h>

Anyidea why autocomplete does not work on the spaceScene property?

#import <Foundation/Foundation.h>
#import "cocos2d.h"
@class SpaceScene;


@interface SpaceSceneSingleton : NSObject 
{    
    SpaceScene *spaceScene;


}

@property (assign) SpaceScene *spaceScene;


+(SpaceSceneSingleton*)sharedSpaceSceneSingleton;
-(void) addChildToSceneWith:(CCNode *) node andWithZindex: (int) zIndex;
-(void) runAction:(CCAction*) action;
-(void) setTouchIsEnabled:(BOOL) isEnabled;
-(void) removeChild: (CCNode *) child;
@end


#import "SpaceSceneSingleton.h"


@implementation SpaceSceneSingleton
@synthesize spaceScene;

static SpaceSceneSingleton* _sharedSpaceSceneSingleton = nil;

+(SpaceSceneSingleton*)sharedSpaceSceneSingleton;
{
    @synchronized([SpaceSceneSingleton class])
    {
        if (!_sharedSpaceSceneSingleton)
            [[self allo开发者_StackOverflow社区c] init];

        return _sharedSpaceSceneSingleton;
    }

    return nil;
}



+(id)alloc
{
    @synchronized([SpaceSceneSingleton class])
    {
        NSAssert(_sharedSpaceSceneSingleton == nil, @"Attempted to allocate a second instance of a singleton.");
        _sharedSpaceSceneSingleton = [super alloc];
        return _sharedSpaceSceneSingleton;
    }

    return nil;
}

-(id)init {
    self = [super init];
    if (self != nil) {
        // initialize stuff here
    }

    return self;
}

-(void) addChildToSceneWith:(CCNode *) node andWithZindex: (int) zIndex
{
    [self.spaceScene addChild:node z:zIndex];

}


-(void) runAction:(CCAction*) action
{

//[self.spaceScene add

}

-(void) setTouchIsEnabled:(BOOL) isEnabled
{

}

-(void) removeChild: (CCNode *) child
{
}
@end


You only declared @class SpaceScene; so within this scope nothing more is known than that a class called SpaceScene might exist. Maybe importing SpaceScene.h helps.

I would even say this should compile with warnings. Does it?

0

精彩评论

暂无评论...
验证码 换一张
取 消