使用Apportable构建应用程序时出现NS_ENUM错误

时间:2014-05-14 19:17:00

标签: android ios enums cocos2d-iphone apportable

我在我的Cocos2d-Iphone应用程序中使用了几个NS_ENUM,我使用Apportable移植到Android。该应用程序在Xcode中运行良好,但在使用Apportable构建时,我在NS_ENUM中遇到了一些错误。以下是一些错误:

/Users/mac/Documents/BallTestApp/BallManager.mm:57:32: error: assigning to 'ballTypes' from incompatible type 'int'
    lastCreatedBallType = NULL;
                        ^ ~~~~
/Users/mac/Documents/BallTestApp/BallManager.mm:382:66: error: cannot initialize a parameter of type 'ballTypes' with an lvalue of type 'int'
                                     withBallType:pBallType atLocation:ballPosition withManager:self];
                                                  ^~~~~~~~~
/Users/mac/Documents/BallTestApp/Ball.h:193:103: note: passing argument to parameter 'myType' here
-(id)initBallWithWorld:(b2World*)world inLayer:(GamePlayLayer*)layer withBallType:(ballTypes)myType atLocation:(CGPoint)myLocation withManager:(BallManager*)myBallManager;
                                                                                             ^
/Users/mac/Documents/BallTestApp/BallManager.mm:575:79: error: cannot initialize a parameter of type 'xBallDistances' with an lvalue of type 'int'
    myBallPos = self.carlBall.position.x  + [self getBallDistance:i];
                                                                  ^

我将ballTypes定义为:

typedef NS_ENUM(NSUInteger, ballTypes)  {

redBall = 0, 
yellowBall = 1,
blueBall = 2,
greenBall = 3
};

我也以类似的方式定义了我的其他枚举。

1 个答案:

答案 0 :(得分:0)

NULL定义如下:

 #define NULL 0

因此,您尝试将int 0分配给枚举值。

使用= redBall代替= NULL将解决警告。