Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用Apportable生成应用程序时出现NS_枚举错误_Android_Ios_Enums_Cocos2d Iphone_Apportable - Fatal编程技术网

Android 使用Apportable生成应用程序时出现NS_枚举错误

Android 使用Apportable生成应用程序时出现NS_枚举错误,android,ios,enums,cocos2d-iphone,apportable,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' la

我在我的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];
                                                                  ^
我将BallType定义为:

typedef NS_ENUM(NSUInteger, ballTypes)  {

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

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

NULL的定义如下:

 #define NULL 0
因此,您试图将int 0分配给枚举值


使用
=redBall
而不是
=NULL
将解决警告问题。

如果在xcode中启用建议的编译器警告,则会出现相同的错误。只需强制转换这些值,并使用0或更好的实际枚举名,而不是NULL(为指针类型保留)。示例:type=(ballTypes)redBall。