Constants.h
私は私のプロジェクトのファイルでこの小さな男を宣言しました:
extern int *exitDirection;
次に、彼を整数に設定しました。この場合、881でした。これは非常に良い数値です。
ここで、プロジェクトの他の場所のswitchステートメントで彼を使用したいと思います。
switch (exitDirection) {
case kExitDirectionLeft:
// Have him spawn on the right of the next level.
break;
case kExitDirectionRight:
// Have him spawn on the left of the next level.
break;
default:
break;
}
}
素敵なエラーメッセージが表示されます"Statement requires expression of integer type (int * invalid)
。これは、実際の整数ではなく、整数へのポインタを指定していることを意味していると思います。kExitDirectionLeftは#define
881と同じですが、実際の数値で切り替えてみましたが、喜びはありません。また、intをNSNumberまたはNSIntegerに切り替えてみましたが、同じエラーです。
この場合、なぜこの外部で定義された整数を使用できないのですか?どうすればそれを機能させることができますか?助けていただければ幸いです。
修正しましたが、そうすることで、このApple Mach-Oリンカー(Id)エラーをトリガーしています。
"_exitDirection", referenced from:
-[GameplayLayer positionHeroMale] in GameplayLayer.o
-[GameCharacter checkAndClampSpritePosition] in GameCharacter.o
-[GameplayLayer positionHeroMale] in GameplayLayer.o
-[GameCharacter checkAndClampSpritePosition] in GameCharacter.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
何か案は?