The dimensions are unknown at compile time, so I'm trying to allocate a 2D array of structs dynamically. The code compiles but I get a bad access when accessing an element.
// The struct
typedef struct
{
NSInteger numActors;
Actor *a1;
Actor *a2;
Actor *a3;
Actor *a4;
Actor *a5;
} GridNode;
// In interface
GridNode **grid;
// In init
NSInteger nx = inFrame.size.width / blockSize;
NSInteger ny = inFrame.size.height / blockSize;
grid = malloc(sizeof(GridNode) * nx * ny);
grid[10][20].numActors = 3; // EXC_BAD_ACCESS