Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am doing tutorials to learn Cocos2d and have a question. here is the .m code:

#import "SceneManager.h"

@interface SceneManager ()
   +(void) go: (CCLayer *) layer;
   +(CCScene *) wrap: (CCLayer *) layer;

@implementation SceneManager

    +(void) goPlay {
        CCLayer *layer = [PlayLayer node];
        [SceneManager go: layer];

+(void) go: (CCLayer *) layer {
    CCDirector *director = [CCDirector sharedDirector];
    CCScene *newScene = [SceneManager wrap:layer];

//    Class transition = nextTransition();

    if ([director runningScene]) {
         [director replaceScene:newScene];
}else {
    [director runWithScene:newScene];

+(CCScene *)wrap: (CCLayer *) layer {
    CCScene *newScene = [CCScene node];
    [newScene addChild: layer];
    return newScene;


My question is why is there an @interface placed in the .m file and not included in the .h file?

share|improve this question
up vote 2 down vote accepted

That @interface Class () placed in the implementation file is a class extension to the SceneManager class which defines its private interface.

It's being used because go and wrap are only used by the implementation of this class and nowhere else (i.e. it's a private interface).

The @private modifier only works on variables, not on methods, so this is the way to hide them.

(Source: stackoverflow)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.