Vishwas
Vishwas

Reputation: 1541

fatal error: method declaration not in @interface context

What does this error mean ? Following is my code. But I don't see anything wrong

-(id) init
{
    if( (self=[super init] )) {
        CGSize winSize = [[CCDirector sharedDirector] winSize];
        CCSprite *player = [CCSprite spriteWithFile:@"Player.png" 
                                               rect:CGRectMake(0, 0, 27, 40)];
        player.position = ccp(player.contentSize.width/2, winSize.height/2);
        [self addChild:player];     
    }

    if( (self=[super initWithColor:ccc4(255,255,255,255)] )) 
    {
    }
    return self;
}

Upvotes: 0

Views: 113

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

You get this error if you write a property or method declaration outside of the @interface … @end block, specifically if you place it either before @interface or after @end. Here's an example that would cause this error:

@interface MyClass : NSObject
{
    // instance vars here
}

// properties and method declarations here

@end

// ERROR: method declared outside @interface (after @end)
-(void) someMethodWithObject:(id)obj;

Upvotes: 1

Related Questions