簡體   English   中英

使用Apportable構建應用時出現NS_ENUM錯誤

[英]NS_ENUM errors when building app using 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
};

我也以類似的方式定義了其他枚舉。

NULL的定義如下:

 #define NULL 0

因此,您試圖將int 0分配給一個枚舉值。

使用= redBall代替= NULL將解決警告。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM