I am currently working on a game, where I am using the turn-based game api from apple's game center. I have been trying to minimize the size of my data i'm sending over Game Center by using c structs.
I have one struct containing data for a turn, and one that holds information about what the current round is and it also has an array containing all the other turns.
However I wanted the array to be dynamic, so I easily can Iterate through it, and I decided to use c++ vectors, which didn't work.
Here is my code so far:
The header:
.h
#import <vector>
typedef struct {
int points; //Points that the player got in this round
int round; // the round number for this turn
char* playerID; //Who's turn was this?
} TurnData ;
typedef struct {
std::vector<TurnData>* turns; //Keep a list over all turns
int currentRound; //What round is it now?
int maxRounds; //How many rounds for this game?
} GameData;
Test implementation:
.m
+(void)test {
GameData data;
data.currentRound = 1;
data.maxRounds = 2;
TurnData turnData;
turnData.round = data.currentRound;
turnData.points = 100;
turnData.playerID = "playerID";
data.turns->push_back(turnData);
GameData loadData = data;
for (std::vector<TurnData>::iterator it = loadData.turns->begin(); it != loadData.turns->end(); ++it) {
NSLog(@"Player: %c, points: %d, round: %d", it->playerID, it->points, it->round);
}
}
When I run this, I get an error saying "Lexical or Preprocessor error. 'vector' file not found"
Any help is much appreciated.