开发者

Calling alloc on a pointer

I'm using cocos2d with objective C.

I have a class called CrystalineBubble that is currently empty it inherits from CCNode.

#import <Foundation/Foundation.h>
#import "cocos2d.h"

@interface CrystalineBubble : CCNode {



}

@end

When I try to create an instance of that class and alloc it I get the warning 'CrystalineBubble' may not respond to开发者_如何学C '-alloc'

here is the line of code where I create and call alloc.

CrystalineBubble* crystaline_bubble = [[crystaline_bubble alloc] init];

I have imported the CrystalineBubble class. The pointer crystaline_bubble isn't being allocated any memory, after stepping over that line it still points to 0x0.

I know I'm doing something incredibly stupid here I just can't spot my error.


This line is incorrect:

CrystalineBubble* crystaline_bubble = [[crystaline_bubble alloc] init];

It should be:

CrystalineBubble* crystaline_bubble = [[CrystalineBubble alloc] init];

+alloc is a class method, not an instance method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜