Hello - I am new to Objective C and am having troubles adding a 2d int array to a NSMutableDictionary. The code errors with "incompatible pointer type" - I assume this is because setObject would be expecting an object..
Here is the code - I am trying to have a Dictionary containing my level data:
NSMutableDictionary *level = [[NSMutableDictionary alloc] init];
[level setObject:@"The Title" forKey:@"title"];
[level setObject:@"level_1" forKey:@"slug"];
int levelTiles[10][10] = {
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1}
};
[level setObject:levelTiles forKey:@"tiles"]; // THIS LINE FAILS
I have 2 questions:
- How do I add the int array (or similar) to the dictionary like this?
- Is there a better way to initialise the data for my game?
Thanks for your help,
Lachlan