为什么我的单例属性无法自动完成?

发布于 2024-11-08 23:44:57 字数 1640 浏览 1 评论 0原文

知道为什么自动完成功能不适用于 spaceScene 属性吗?

#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 alloc] 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

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 alloc] 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2024-11-15 23:44:57

您只声明了 @class SpaceScene;,因此在此范围内,除了可能存在名为 SpaceScene 的类之外,我们一无所知。也许导入 SpaceScene.h 会有所帮助。

我什至会说这应该带有警告编译。是吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文