I am having trouble creating a type of my custom class Frank. When I do I receive the following error:
Class method ‘+initWithWorld::’ not found (return type defaults to
‘id’)
My class is defined as so:
@interface Frank : NSObject {
PhysicsSprite *frankSprite;
b2Body *body;
float weight;
}
@property (readonly) b2Body *body;
-(void)initWithWorld:(b2World *) world :(CCNode *)parent;
-(void)moveLeft;
-(void)moveRight;
@end
I create the object like so:
frank = [Frank initWithWorld:world :self];
What am I doing wrong?
An object needs to be allocated first:
Your
initmethod is a member method (width a-sign), meaning you need to call it on an allocated object, as opposed to class methods (with a+sign).Edit
As pointed by @JustSid, such an
initmethod must also return an object (typeid).So the correct method prototype is:
The implementation should then be something like: