小编Aei*_*sys的帖子

无法初始化一个类对象:objective-C

我正在尝试创建一个简单的CCNode子类,但我无法创建该对象.

它给出了错误" *因未捕获的异常而终止应用程序'NSInvalidArgumentException',原因:'* + [ContentPane <0x206898> init]:无法初始化类对象.'"

这是我的CCNode的子类:

#import "ContentPane.h"

@implementation ContentPane{
    int content[8][4];
    CCSprite *_rockPath1;
    CCSprite *_rockPath2;
}

- (id)init {
    self = [super init];

    if (self) {
        CCLOG(@"ContentPane created");
    }

    return self;
}
Run Code Online (Sandbox Code Playgroud)

@结束

这是我尝试启动它的地方:

- (void)didLoadFromCCB {
    // tell this scene to accept touches
    self.userInteractionEnabled = TRUE;
    _counter = 0;
    ContentPane *pane = [ContentPane init];
}
Run Code Online (Sandbox Code Playgroud)

subclass objective-c init cocos2d-iphone

8
推荐指数
1
解决办法
7929
查看次数

标签 统计

cocos2d-iphone ×1

init ×1

objective-c ×1

subclass ×1