Q:

duplicate symbols

Still working on my game, and fir each difficulty I have a "gameSpeed" this is set depending on the difficult chosen.
However when trying to run my application I get the following error:
duplicate symbol _gameSpeed in:
/Users/Ashley/Library/Developer/Xcode/DerivedData/Whack-etfeadnxmmtdkgdoyvgumsuaapsz/Build/Intermediates/Whack.build/Debug-iphonesimulator/Whack.build/Objects-normal/i386/TimedGameLayer.o
/Users/Ashley/Library/Developer/Xcode/DerivedData/Whack-etfeadnxmmtdkgdoyvgumsuaapsz/Build/Intermediates/Whack.build/Debug-iphonesimulator/Whack.build/Objects-normal/i386/GameInfo.o
ld: 1 duplicate symbols for architecture i386
collect2: ld returned 1 exit status
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

I am only using gameSpeed in one location.
which is here:
[self schedule:@selector(tryPopMoles:) interval:gameSpeed];

this is inside my TimedGameLayer.m
The gameSpeed var is in my GameInfo.h
I import the header like so:
#import "GameInfo.h"

My GameInfo.h looks like this:
@interface GameInfo : NSObject
+(void)setupGame:(enum GameType)type withArg2:(enum GameDifficulty)difficulty;
+(void)resetGame;
+(void)togglePause;

@end

//Game Type
enum GameType gameType;
enum GameDifficulty gameDifficulty;

//Release Version
NSString *version;

//Settings
int gameSpeed = 1.5;

//Stats
int touches = 0;
int score = 0;
int totalSpawns = 0;

//usables
bool gamePaused = FALSE;

typedef enum GameType {
    GameTypeClassic = 0,
    GameTypeUnlimited,
    GameTypeTimed,
    GameTypeExpert,
} GameType;

typedef enum GameDifficulty
{
    GameDifficultyEasy = 0,
    GameDifficultyMedium,
    GameDifficultyHard,
} GameDifficulty;

My setupGame function(which is in my GameInfo.m file) looks like this:
+(void)setupGame:(enum GameType)type withArg2:(enum GameDifficulty)difficulty
{
    gameType = type;
    gameDifficulty = difficulty;

    switch(gameDifficulty)
    {
        case GameDifficultyEasy:
            gameSpeed = 1.5;
            break;
        case GameDifficultyMedium:
            gameSpeed = 1.0;
            break;
        case GameDifficultyHard:
            gameSpeed = 0.5;
            break;
    }
}

Im completely lost here...
Any ideas?
Thanks

A:

Based on your comments below and your example code:
You have a series of variables declared in the .h file, and the .h file is included multiple times, so you have multiple variables with the same name. You should create a constants.h and constants.m file and declare that list as constants in the constants file.
constants.h:
extern const int gameSpeed;

constants.m:
const int gameSpeed = 1;

By the way, you're declaring gameSpeed as an int but assign a float value to it, so gameSpeed will be equal to 1. Use a float type instead.

